mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Moved modifier related flags to separate enum
This commit is contained in:
+16
-17
@@ -37,7 +37,7 @@ namespace ts {
|
||||
return ModuleInstanceState.ConstEnumOnly;
|
||||
}
|
||||
// 3. non-exported import declarations
|
||||
else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && !(node.flags & NodeFlags.Export)) {
|
||||
else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && !(getModifierFlags(node) & ModifierFlags.Export)) {
|
||||
return ModuleInstanceState.NonInstantiated;
|
||||
}
|
||||
// 4. other uninstantiated module declarations.
|
||||
@@ -256,7 +256,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return node.flags & NodeFlags.Default ? "default" : undefined;
|
||||
return getModifierFlags(node) & ModifierFlags.Default ? "default" : undefined;
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
return isJSDocConstructSignature(node) ? "__new" : "__call";
|
||||
case SyntaxKind.Parameter:
|
||||
@@ -284,7 +284,7 @@ namespace ts {
|
||||
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
|
||||
const isDefaultExport = node.flags & NodeFlags.Default;
|
||||
const isDefaultExport = getModifierFlags(node) & ModifierFlags.Default;
|
||||
// The exported symbol for an export default function/class node is always named "default"
|
||||
const name = isDefaultExport && parent ? "default" : getDeclarationName(node);
|
||||
|
||||
@@ -329,7 +329,7 @@ namespace ts {
|
||||
: Diagnostics.Duplicate_identifier_0;
|
||||
|
||||
forEach(symbol.declarations, declaration => {
|
||||
if (declaration.flags & NodeFlags.Default) {
|
||||
if (getModifierFlags(declaration) & ModifierFlags.Default) {
|
||||
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
|
||||
}
|
||||
});
|
||||
@@ -353,7 +353,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol {
|
||||
const hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;
|
||||
const hasExportModifier = getCombinedModifierFlags(node) & ModifierFlags.Export;
|
||||
if (symbolFlags & SymbolFlags.Alias) {
|
||||
if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) {
|
||||
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
|
||||
@@ -862,7 +862,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
|
||||
return node.flags & NodeFlags.Static
|
||||
return getModifierFlags(node) & ModifierFlags.Static
|
||||
? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes)
|
||||
: declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
@@ -899,7 +899,7 @@ namespace ts {
|
||||
function bindModuleDeclaration(node: ModuleDeclaration) {
|
||||
setExportContextFlag(node);
|
||||
if (isAmbientModule(node)) {
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (getModifierFlags(node) & ModifierFlags.Export) {
|
||||
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
|
||||
}
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
|
||||
@@ -1800,7 +1800,7 @@ namespace ts {
|
||||
*/
|
||||
export function computeTransformFlagsForNode(node: Node, subtreeFlags: TransformFlags): TransformFlags {
|
||||
// Ambient nodes are TypeScript syntax and the flags of their subtree are ignored.
|
||||
if (node.flags & NodeFlags.Ambient) {
|
||||
if (getModifierFlags(node) & ModifierFlags.Ambient) {
|
||||
return (node.transformFlags = TransformFlags.AssertTypeScript)
|
||||
& ~(node.excludeTransformFlags = TransformFlags.NodeExcludes);
|
||||
}
|
||||
@@ -2008,7 +2008,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// If a parameter has an accessibility modifier, then it is TypeScript syntax.
|
||||
if ((<ParameterDeclaration>node).flags & NodeFlags.AccessibilityModifier) {
|
||||
if (getModifierFlags(node) & ModifierFlags.AccessibilityModifier) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.ContainsParameterPropertyAssignments;
|
||||
}
|
||||
|
||||
@@ -2033,7 +2033,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// An async arrow function is TypeScript syntax.
|
||||
if (node.flags & NodeFlags.Async) {
|
||||
if (getModifierFlags(node) & ModifierFlags.Async) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@@ -2052,7 +2052,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// An async function expression is TypeScript syntax.
|
||||
if (node.flags & NodeFlags.Async) {
|
||||
if (getModifierFlags(node) & ModifierFlags.Async) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@@ -2072,14 +2072,14 @@ namespace ts {
|
||||
// subtree has marked the container as needing to capture the lexical `this`,
|
||||
// then this node is ES6 syntax.
|
||||
if ((<FunctionDeclaration>node).asteriskToken
|
||||
|| node.flags & NodeFlags.Export
|
||||
|| getModifierFlags(node) & ModifierFlags.Export
|
||||
|| subtreeFlags & TransformFlags.ContainsCapturedLexicalThis
|
||||
|| subtreeFlags & TransformFlags.ContainsDefaultValueAssignments) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
}
|
||||
|
||||
// An async function declaration is TypeScript syntax.
|
||||
if (node.flags & NodeFlags.Async) {
|
||||
if (getModifierFlags(node) & ModifierFlags.Async) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@@ -2103,7 +2103,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.VariableStatement:
|
||||
// If a VariableStatement is exported, then it is either ES6 or TypeScript syntax.
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (getModifierFlags(node) & ModifierFlags.Export) {
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@@ -2204,8 +2204,7 @@ namespace ts {
|
||||
// generic, or has both a computed property name and a decorator.
|
||||
if ((<MethodDeclaration>node).body === undefined
|
||||
|| (<MethodDeclaration>node).typeParameters !== undefined
|
||||
|| node.flags & NodeFlags.Async
|
||||
|| node.flags & NodeFlags.Abstract
|
||||
|| getModifierFlags(node) & (ModifierFlags.Async | ModifierFlags.Abstract)
|
||||
|| (subtreeFlags & TransformFlags.ContainsDecorators
|
||||
&& subtreeFlags & TransformFlags.ContainsComputedPropertyName)) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
@@ -2220,7 +2219,7 @@ namespace ts {
|
||||
|
||||
// A GetAccessor or SetAccessor is TypeScript syntax if it is either abstract,
|
||||
// or has both a computed property name and a decorator.
|
||||
if (node.flags & NodeFlags.Abstract ||
|
||||
if (getModifierFlags(node) & ModifierFlags.Abstract ||
|
||||
subtreeFlags & TransformFlags.ContainsDecorators &&
|
||||
subtreeFlags & TransformFlags.ContainsComputedPropertyName) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
|
||||
+123
-120
@@ -535,7 +535,7 @@ namespace ts {
|
||||
|
||||
const initializerOfNonStaticProperty = current.parent &&
|
||||
current.parent.kind === SyntaxKind.PropertyDeclaration &&
|
||||
(current.parent.flags & NodeFlags.Static) === 0 &&
|
||||
(getModifierFlags(current.parent) & ModifierFlags.Static) === 0 &&
|
||||
(<PropertyDeclaration>current.parent).initializer === current;
|
||||
|
||||
if (initializerOfNonStaticProperty) {
|
||||
@@ -653,7 +653,7 @@ namespace ts {
|
||||
// local variables of the constructor. This effectively means that entities from outer scopes
|
||||
// by the same name as a constructor parameter or local variable are inaccessible
|
||||
// in initializer expressions for instance member variables.
|
||||
if (isClassLike(location.parent) && !(location.flags & NodeFlags.Static)) {
|
||||
if (isClassLike(location.parent) && !(getModifierFlags(location) & ModifierFlags.Static)) {
|
||||
const ctor = findConstructorDeclaration(<ClassLikeDeclaration>location.parent);
|
||||
if (ctor && ctor.locals) {
|
||||
if (getSymbol(ctor.locals, name, meaning & SymbolFlags.Value)) {
|
||||
@@ -667,7 +667,7 @@ namespace ts {
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & SymbolFlags.Type)) {
|
||||
if (lastLocation && lastLocation.flags & NodeFlags.Static) {
|
||||
if (lastLocation && getModifierFlags(lastLocation) & ModifierFlags.Static) {
|
||||
// TypeScript 1.0 spec (April 2014): 3.4.1
|
||||
// The scope of a type parameter extends over the entire declaration with which the type
|
||||
// parameter list is associated, with the exception of static member declarations in classes.
|
||||
@@ -824,7 +824,7 @@ namespace ts {
|
||||
|
||||
// No static member is present.
|
||||
// Check if we're in an instance method and look for a relevant instance member.
|
||||
if (location === container && !(location.flags & NodeFlags.Static)) {
|
||||
if (location === container && !(getModifierFlags(location) & ModifierFlags.Static)) {
|
||||
const instanceType = (<InterfaceType>getDeclaredTypeOfSymbol(classSymbol)).thisType;
|
||||
if (getPropertyOfType(instanceType, name)) {
|
||||
error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
|
||||
@@ -1617,7 +1617,7 @@ namespace ts {
|
||||
|
||||
const anyImportSyntax = getAnyImportSyntax(declaration);
|
||||
if (anyImportSyntax &&
|
||||
!(anyImportSyntax.flags & NodeFlags.Export) && // import clause without export
|
||||
!(getModifierFlags(anyImportSyntax) & ModifierFlags.Export) && // import clause without export
|
||||
isDeclarationVisible(<Declaration>anyImportSyntax.parent)) {
|
||||
getNodeLinks(declaration).isVisible = true;
|
||||
if (aliasesToMakeVisible) {
|
||||
@@ -2014,7 +2014,7 @@ namespace ts {
|
||||
|
||||
function shouldWriteTypeOfFunctionSymbol() {
|
||||
const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method
|
||||
forEach(symbol.declarations, declaration => declaration.flags & NodeFlags.Static));
|
||||
forEach(symbol.declarations, declaration => getModifierFlags(declaration) & ModifierFlags.Static));
|
||||
const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) &&
|
||||
(symbol.parent || // is exported function symbol
|
||||
forEach(symbol.declarations, declaration =>
|
||||
@@ -2306,7 +2306,7 @@ namespace ts {
|
||||
}
|
||||
const parent = getDeclarationContainer(node);
|
||||
// If the node is not exported or it is not ambient module element (except import declaration)
|
||||
if (!(getCombinedNodeFlags(node) & NodeFlags.Export) &&
|
||||
if (!(getCombinedModifierFlags(node) & ModifierFlags.Export) &&
|
||||
!(node.kind !== SyntaxKind.ImportEqualsDeclaration && parent.kind !== SyntaxKind.SourceFile && isInAmbientContext(parent))) {
|
||||
return isGlobalSourceFile(parent);
|
||||
}
|
||||
@@ -2319,7 +2319,7 @@ namespace ts {
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (node.flags & (NodeFlags.Private | NodeFlags.Protected)) {
|
||||
if (getModifierFlags(node) & (ModifierFlags.Private | ModifierFlags.Protected)) {
|
||||
// Private/protected properties/methods are not visible
|
||||
return false;
|
||||
}
|
||||
@@ -3867,7 +3867,7 @@ namespace ts {
|
||||
const type = getApparentType(current);
|
||||
if (type !== unknownType) {
|
||||
const prop = getPropertyOfType(type, name);
|
||||
if (prop && !(getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected))) {
|
||||
if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (ModifierFlags.Private | ModifierFlags.Protected))) {
|
||||
commonFlags &= prop.flags;
|
||||
if (!props) {
|
||||
props = [prop];
|
||||
@@ -4309,7 +4309,7 @@ namespace ts {
|
||||
const declaration = getIndexDeclarationOfSymbol(symbol, kind);
|
||||
if (declaration) {
|
||||
return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType,
|
||||
(declaration.flags & NodeFlags.Readonly) !== 0, declaration);
|
||||
(getModifierFlags(declaration) & ModifierFlags.Readonly) !== 0, declaration);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -4845,7 +4845,7 @@ namespace ts {
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
const parent = container && container.parent;
|
||||
if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) {
|
||||
if (!(container.flags & NodeFlags.Static) &&
|
||||
if (!(getModifierFlags(container) & ModifierFlags.Static) &&
|
||||
(container.kind !== SyntaxKind.Constructor || isNodeDescendantOf(node, (<ConstructorDeclaration>container).body))) {
|
||||
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
|
||||
}
|
||||
@@ -5791,24 +5791,24 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (!(targetProp.flags & SymbolFlags.Prototype)) {
|
||||
const sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp);
|
||||
const targetPropFlags = getDeclarationFlagsFromSymbol(targetProp);
|
||||
if (sourcePropFlags & NodeFlags.Private || targetPropFlags & NodeFlags.Private) {
|
||||
const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp);
|
||||
const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp);
|
||||
if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) {
|
||||
if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
|
||||
if (reportErrors) {
|
||||
if (sourcePropFlags & NodeFlags.Private && targetPropFlags & NodeFlags.Private) {
|
||||
if (sourcePropFlags & ModifierFlags.Private && targetPropFlags & ModifierFlags.Private) {
|
||||
reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
|
||||
}
|
||||
else {
|
||||
reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp),
|
||||
typeToString(sourcePropFlags & NodeFlags.Private ? source : target),
|
||||
typeToString(sourcePropFlags & NodeFlags.Private ? target : source));
|
||||
typeToString(sourcePropFlags & ModifierFlags.Private ? source : target),
|
||||
typeToString(sourcePropFlags & ModifierFlags.Private ? target : source));
|
||||
}
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
}
|
||||
else if (targetPropFlags & NodeFlags.Protected) {
|
||||
else if (targetPropFlags & ModifierFlags.Protected) {
|
||||
const sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class;
|
||||
const sourceClass = sourceDeclaredInClass ? <InterfaceType>getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined;
|
||||
const targetClass = <InterfaceType>getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp));
|
||||
@@ -5820,7 +5820,7 @@ namespace ts {
|
||||
return Ternary.False;
|
||||
}
|
||||
}
|
||||
else if (sourcePropFlags & NodeFlags.Protected) {
|
||||
else if (sourcePropFlags & ModifierFlags.Protected) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2,
|
||||
symbolToString(targetProp), typeToString(source), typeToString(target));
|
||||
@@ -6060,7 +6060,7 @@ namespace ts {
|
||||
const symbol = type.symbol;
|
||||
if (symbol && symbol.flags & SymbolFlags.Class) {
|
||||
const declaration = getClassLikeDeclarationOfSymbol(symbol);
|
||||
if (declaration && declaration.flags & NodeFlags.Abstract) {
|
||||
if (declaration && getModifierFlags(declaration) & ModifierFlags.Abstract) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -6100,8 +6100,8 @@ namespace ts {
|
||||
if (sourceProp === targetProp) {
|
||||
return Ternary.True;
|
||||
}
|
||||
const sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (NodeFlags.Private | NodeFlags.Protected);
|
||||
const targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected);
|
||||
const sourcePropAccessibility = getDeclarationModifierFlagsFromSymbol(sourceProp) & ModifierFlags.NonPublicAccessibilityModifier;
|
||||
const targetPropAccessibility = getDeclarationModifierFlagsFromSymbol(targetProp) & ModifierFlags.NonPublicAccessibilityModifier;
|
||||
if (sourcePropAccessibility !== targetPropAccessibility) {
|
||||
return Ternary.False;
|
||||
}
|
||||
@@ -7323,7 +7323,7 @@ namespace ts {
|
||||
break;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
if (container.flags & NodeFlags.Static) {
|
||||
if (getModifierFlags(container) & ModifierFlags.Static) {
|
||||
error(node, Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
|
||||
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
|
||||
}
|
||||
@@ -7339,7 +7339,7 @@ namespace ts {
|
||||
|
||||
if (isClassLike(container.parent)) {
|
||||
const symbol = getSymbolOfNode(container.parent);
|
||||
return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (<InterfaceType>getDeclaredTypeOfSymbol(symbol)).thisType;
|
||||
return getModifierFlags(container) & ModifierFlags.Static ? getTypeOfSymbol(symbol) : (<InterfaceType>getDeclaredTypeOfSymbol(symbol)).thisType;
|
||||
}
|
||||
|
||||
if (isInJavaScriptFile(node)) {
|
||||
@@ -7429,7 +7429,7 @@ namespace ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if ((container.flags & NodeFlags.Static) || isCallExpression) {
|
||||
if ((getModifierFlags(container) & ModifierFlags.Static) || isCallExpression) {
|
||||
nodeCheckFlag = NodeCheckFlags.SuperStatic;
|
||||
}
|
||||
else {
|
||||
@@ -7494,7 +7494,7 @@ namespace ts {
|
||||
// This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set.
|
||||
// This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment
|
||||
// while a property access can.
|
||||
if (container.kind === SyntaxKind.MethodDeclaration && container.flags & NodeFlags.Async) {
|
||||
if (container.kind === SyntaxKind.MethodDeclaration && getModifierFlags(container) & ModifierFlags.Async) {
|
||||
if (isSuperProperty(node.parent) && isAssignmentTarget(node.parent)) {
|
||||
getNodeLinks(container).flags |= NodeCheckFlags.AsyncMethodWithSuperBinding;
|
||||
}
|
||||
@@ -7560,7 +7560,7 @@ namespace ts {
|
||||
|
||||
// topmost container must be something that is directly nested in the class declaration\object literal expression
|
||||
if (isClassLike(container.parent) || container.parent.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
if (container.flags & NodeFlags.Static) {
|
||||
if (getModifierFlags(container) & ModifierFlags.Static) {
|
||||
return container.kind === SyntaxKind.MethodDeclaration ||
|
||||
container.kind === SyntaxKind.MethodSignature ||
|
||||
container.kind === SyntaxKind.GetAccessor ||
|
||||
@@ -8785,8 +8785,12 @@ namespace ts {
|
||||
return s.valueDeclaration ? s.valueDeclaration.kind : SyntaxKind.PropertyDeclaration;
|
||||
}
|
||||
|
||||
function getDeclarationFlagsFromSymbol(s: Symbol): NodeFlags {
|
||||
return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0;
|
||||
function getDeclarationModifierFlagsFromSymbol(s: Symbol): ModifierFlags {
|
||||
return s.valueDeclaration ? getCombinedModifierFlags(s.valueDeclaration) : s.flags & SymbolFlags.Prototype ? ModifierFlags.Public | ModifierFlags.Static : 0;
|
||||
}
|
||||
|
||||
function getDeclarationNodeFlagsFromSymbol(s: Symbol): NodeFlags {
|
||||
return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8798,7 +8802,7 @@ namespace ts {
|
||||
* @param prop The symbol for the right hand side of the property access.
|
||||
*/
|
||||
function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean {
|
||||
const flags = getDeclarationFlagsFromSymbol(prop);
|
||||
const flags = getDeclarationModifierFlagsFromSymbol(prop);
|
||||
const declaringClass = <InterfaceType>getDeclaredTypeOfSymbol(getParentOfSymbol(prop));
|
||||
|
||||
if (left.kind === SyntaxKind.SuperKeyword) {
|
||||
@@ -8821,7 +8825,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flags & NodeFlags.Abstract) {
|
||||
if (flags & ModifierFlags.Abstract) {
|
||||
// A method cannot be accessed in a super property access if the method is abstract.
|
||||
// This error could mask a private property access error. But, a member
|
||||
// cannot simultaneously be private and abstract, so this will trigger an
|
||||
@@ -8833,7 +8837,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Public properties are otherwise accessible.
|
||||
if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) {
|
||||
if (!(flags & ModifierFlags.NonPublicAccessibilityModifier)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8844,7 +8848,7 @@ namespace ts {
|
||||
const enclosingClass = enclosingClassDeclaration ? <InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined;
|
||||
|
||||
// Private property is accessible if declaring and enclosing class are the same
|
||||
if (flags & NodeFlags.Private) {
|
||||
if (flags & ModifierFlags.Private) {
|
||||
if (declaringClass !== enclosingClass) {
|
||||
error(node, Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass));
|
||||
return false;
|
||||
@@ -8864,7 +8868,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
// No further restrictions for static properties
|
||||
if (flags & NodeFlags.Static) {
|
||||
if (flags & ModifierFlags.Static) {
|
||||
return true;
|
||||
}
|
||||
// An instance property must be accessed through an instance of the enclosing class
|
||||
@@ -10082,7 +10086,7 @@ namespace ts {
|
||||
// In the case of a merged class-module or class-interface declaration,
|
||||
// only the class declaration node will have the Abstract flag set.
|
||||
const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
|
||||
if (valueDecl && valueDecl.flags & NodeFlags.Abstract) {
|
||||
if (valueDecl && getModifierFlags(valueDecl) & ModifierFlags.Abstract) {
|
||||
error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name));
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
@@ -10700,8 +10704,8 @@ namespace ts {
|
||||
// Variables declared with 'const'
|
||||
// Get accessors without matching set accessors
|
||||
// Enum members
|
||||
return symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 ||
|
||||
symbol.flags & SymbolFlags.Variable && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 ||
|
||||
return symbol.flags & SymbolFlags.Property && (getDeclarationModifierFlagsFromSymbol(symbol) & ModifierFlags.Readonly) !== 0 ||
|
||||
symbol.flags & SymbolFlags.Variable && (getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 ||
|
||||
symbol.flags & SymbolFlags.Accessor && !(symbol.flags & SymbolFlags.SetAccessor) ||
|
||||
(symbol.flags & SymbolFlags.EnumMember) !== 0;
|
||||
}
|
||||
@@ -11516,7 +11520,7 @@ namespace ts {
|
||||
|
||||
checkVariableLikeDeclaration(node);
|
||||
let func = getContainingFunction(node);
|
||||
if (node.flags & NodeFlags.AccessibilityModifier) {
|
||||
if (getModifierFlags(node) & ModifierFlags.AccessibilityModifier) {
|
||||
func = getContainingFunction(node);
|
||||
if (!(func.kind === SyntaxKind.Constructor && nodeIsPresent(func.body))) {
|
||||
error(node, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
|
||||
@@ -11760,7 +11764,7 @@ namespace ts {
|
||||
|
||||
// Abstract methods cannot have an implementation.
|
||||
// Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node.
|
||||
if (node.flags & NodeFlags.Abstract && node.body) {
|
||||
if (getModifierFlags(node) & ModifierFlags.Abstract && node.body) {
|
||||
error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name));
|
||||
}
|
||||
}
|
||||
@@ -11822,7 +11826,7 @@ namespace ts {
|
||||
|
||||
function isInstancePropertyWithInitializer(n: Node): boolean {
|
||||
return n.kind === SyntaxKind.PropertyDeclaration &&
|
||||
!(n.flags & NodeFlags.Static) &&
|
||||
!(getModifierFlags(n) & ModifierFlags.Static) &&
|
||||
!!(<PropertyDeclaration>n).initializer;
|
||||
}
|
||||
|
||||
@@ -11847,7 +11851,7 @@ namespace ts {
|
||||
// or the containing class declares instance member variables with initializers.
|
||||
const superCallShouldBeFirst =
|
||||
forEach((<ClassDeclaration>node.parent).members, isInstancePropertyWithInitializer) ||
|
||||
forEach(node.parameters, p => p.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected));
|
||||
forEach(node.parameters, p => getModifierFlags(p) & ModifierFlags.AccessibilityModifier);
|
||||
|
||||
// Skip past any prologue directives to find the first statement
|
||||
// to ensure that it was a super call.
|
||||
@@ -11905,7 +11909,7 @@ namespace ts {
|
||||
const otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
|
||||
const otherAccessor = <AccessorDeclaration>getDeclarationOfKind(node.symbol, otherKind);
|
||||
if (otherAccessor) {
|
||||
if (((node.flags & NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & NodeFlags.AccessibilityModifier))) {
|
||||
if ((getModifierFlags(node) & ModifierFlags.AccessibilityModifier) !== (getModifierFlags(otherAccessor) & ModifierFlags.AccessibilityModifier)) {
|
||||
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
|
||||
}
|
||||
|
||||
@@ -12006,11 +12010,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isPrivateWithinAmbient(node: Node): boolean {
|
||||
return (node.flags & NodeFlags.Private) && isInAmbientContext(node);
|
||||
return (getModifierFlags(node) & ModifierFlags.Private) && isInAmbientContext(node);
|
||||
}
|
||||
|
||||
function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags): NodeFlags {
|
||||
let flags = getCombinedNodeFlags(n);
|
||||
function getEffectiveDeclarationFlags(n: Node, flagsToCheck: ModifierFlags): ModifierFlags {
|
||||
let flags = getCombinedModifierFlags(n);
|
||||
|
||||
// children of classes (even ambient classes) should not be marked as ambient or export
|
||||
// because those flags have no useful semantics there.
|
||||
@@ -12018,11 +12022,11 @@ namespace ts {
|
||||
n.parent.kind !== SyntaxKind.ClassDeclaration &&
|
||||
n.parent.kind !== SyntaxKind.ClassExpression &&
|
||||
isInAmbientContext(n)) {
|
||||
if (!(flags & NodeFlags.Ambient)) {
|
||||
if (!(flags & ModifierFlags.Ambient)) {
|
||||
// It is nested in an ambient context, which means it is automatically exported
|
||||
flags |= NodeFlags.Export;
|
||||
flags |= ModifierFlags.Export;
|
||||
}
|
||||
flags |= NodeFlags.Ambient;
|
||||
flags |= ModifierFlags.Ambient;
|
||||
}
|
||||
|
||||
return flags & flagsToCheck;
|
||||
@@ -12043,7 +12047,7 @@ namespace ts {
|
||||
return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
|
||||
}
|
||||
|
||||
function checkFlagAgreementBetweenOverloads(overloads: Declaration[], implementation: FunctionLikeDeclaration, flagsToCheck: NodeFlags, someOverloadFlags: NodeFlags, allOverloadFlags: NodeFlags): void {
|
||||
function checkFlagAgreementBetweenOverloads(overloads: Declaration[], implementation: FunctionLikeDeclaration, flagsToCheck: ModifierFlags, someOverloadFlags: ModifierFlags, allOverloadFlags: ModifierFlags): void {
|
||||
// Error if some overloads have a flag that is not shared by all overloads. To find the
|
||||
// deviations, we XOR someOverloadFlags with allOverloadFlags
|
||||
const someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
|
||||
@@ -12052,16 +12056,16 @@ namespace ts {
|
||||
|
||||
forEach(overloads, o => {
|
||||
const deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags;
|
||||
if (deviation & NodeFlags.Export) {
|
||||
if (deviation & ModifierFlags.Export) {
|
||||
error(o.name, Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported);
|
||||
}
|
||||
else if (deviation & NodeFlags.Ambient) {
|
||||
else if (deviation & ModifierFlags.Ambient) {
|
||||
error(o.name, Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
|
||||
}
|
||||
else if (deviation & (NodeFlags.Private | NodeFlags.Protected)) {
|
||||
else if (deviation & (ModifierFlags.Private | ModifierFlags.Protected)) {
|
||||
error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
|
||||
}
|
||||
else if (deviation & NodeFlags.Abstract) {
|
||||
else if (deviation & ModifierFlags.Abstract) {
|
||||
error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract);
|
||||
}
|
||||
});
|
||||
@@ -12080,8 +12084,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
const flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected | NodeFlags.Abstract;
|
||||
let someNodeFlags: NodeFlags = 0;
|
||||
const flagsToCheck: ModifierFlags = ModifierFlags.Export | ModifierFlags.Ambient | ModifierFlags.Private | ModifierFlags.Protected | ModifierFlags.Abstract;
|
||||
let someNodeFlags: ModifierFlags = ModifierFlags.None;
|
||||
let allNodeFlags = flagsToCheck;
|
||||
let someHaveQuestionToken = false;
|
||||
let allHaveQuestionToken = true;
|
||||
@@ -12116,13 +12120,13 @@ namespace ts {
|
||||
if (node.name && (<FunctionLikeDeclaration>subsequentNode).name && (<Identifier>node.name).text === (<Identifier>(<FunctionLikeDeclaration>subsequentNode).name).text) {
|
||||
const reportError =
|
||||
(node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) &&
|
||||
(node.flags & NodeFlags.Static) !== (subsequentNode.flags & NodeFlags.Static);
|
||||
(getModifierFlags(node) & ModifierFlags.Static) !== (getModifierFlags(subsequentNode) & ModifierFlags.Static);
|
||||
// we can get here in two cases
|
||||
// 1. mixed static and instance class members
|
||||
// 2. something with the same name was defined before the set of overloads that prevents them from merging
|
||||
// here we'll report error only for the first case since for second we should already report error in binder
|
||||
if (reportError) {
|
||||
const diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
|
||||
const diagnostic = getModifierFlags(node) & ModifierFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
|
||||
error(errorNode, diagnostic);
|
||||
}
|
||||
return;
|
||||
@@ -12140,7 +12144,7 @@ namespace ts {
|
||||
else {
|
||||
// Report different errors regarding non-consecutive blocks of declarations depending on whether
|
||||
// the node in question is abstract.
|
||||
if (node.flags & NodeFlags.Abstract) {
|
||||
if (getModifierFlags(node) & ModifierFlags.Abstract) {
|
||||
error(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
|
||||
}
|
||||
else {
|
||||
@@ -12219,7 +12223,7 @@ namespace ts {
|
||||
|
||||
// Abstract methods can't have an implementation -- in particular, they don't need one.
|
||||
if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
|
||||
!(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract)) {
|
||||
!(getModifierFlags(lastSeenNonAmbientDeclaration) & ModifierFlags.Abstract)) {
|
||||
reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
|
||||
}
|
||||
|
||||
@@ -12269,10 +12273,10 @@ namespace ts {
|
||||
let defaultExportedDeclarationSpaces = SymbolFlags.None;
|
||||
for (const d of symbol.declarations) {
|
||||
const declarationSpaces = getDeclarationSpaces(d);
|
||||
const effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, NodeFlags.Export | NodeFlags.Default);
|
||||
const effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, ModifierFlags.Export | ModifierFlags.Default);
|
||||
|
||||
if (effectiveDeclarationFlags & NodeFlags.Export) {
|
||||
if (effectiveDeclarationFlags & NodeFlags.Default) {
|
||||
if (effectiveDeclarationFlags & ModifierFlags.Export) {
|
||||
if (effectiveDeclarationFlags & ModifierFlags.Default) {
|
||||
defaultExportedDeclarationSpaces |= declarationSpaces;
|
||||
}
|
||||
else {
|
||||
@@ -13012,7 +13016,7 @@ namespace ts {
|
||||
if (localDeclarationSymbol &&
|
||||
localDeclarationSymbol !== symbol &&
|
||||
localDeclarationSymbol.flags & SymbolFlags.BlockScopedVariable) {
|
||||
if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & NodeFlags.BlockScoped) {
|
||||
if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & NodeFlags.BlockScoped) {
|
||||
const varDeclList = getAncestor(localDeclarationSymbol.valueDeclaration, SyntaxKind.VariableDeclarationList);
|
||||
const container =
|
||||
varDeclList.parent.kind === SyntaxKind.VariableStatement && varDeclList.parent.parent
|
||||
@@ -13788,7 +13792,7 @@ namespace ts {
|
||||
// Only process instance properties with computed names here.
|
||||
// Static properties cannot be in conflict with indexers,
|
||||
// and properties with literal names were already checked.
|
||||
if (!(member.flags & NodeFlags.Static) && hasDynamicName(member)) {
|
||||
if (!(getModifierFlags(member) & ModifierFlags.Static) && hasDynamicName(member)) {
|
||||
const propType = getTypeOfSymbol(member.symbol);
|
||||
checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String);
|
||||
checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number);
|
||||
@@ -13899,7 +13903,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkClassDeclaration(node: ClassDeclaration) {
|
||||
if (!node.name && !(node.flags & NodeFlags.Default)) {
|
||||
if (!node.name && !(getModifierFlags(node) & ModifierFlags.Default)) {
|
||||
grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
|
||||
}
|
||||
checkClassLikeDeclaration(node);
|
||||
@@ -14019,7 +14023,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const derived = getTargetSymbol(getPropertyOfObjectType(type, base.name));
|
||||
const baseDeclarationFlags = getDeclarationFlagsFromSymbol(base);
|
||||
const baseDeclarationFlags = getDeclarationModifierFlagsFromSymbol(base);
|
||||
|
||||
Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
|
||||
|
||||
@@ -14035,7 +14039,7 @@ namespace ts {
|
||||
// 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))) {
|
||||
if (baseDeclarationFlags & ModifierFlags.Abstract && (!derivedClassDecl || !(getModifierFlags(derivedClassDecl) & ModifierFlags.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));
|
||||
@@ -14048,13 +14052,13 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// derived overrides base.
|
||||
const derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived);
|
||||
if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) {
|
||||
const derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived);
|
||||
if ((baseDeclarationFlags & ModifierFlags.Private) || (derivedDeclarationFlags & ModifierFlags.Private)) {
|
||||
// either base or derived property is private - not override, skip it
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((baseDeclarationFlags & NodeFlags.Static) !== (derivedDeclarationFlags & NodeFlags.Static)) {
|
||||
if ((baseDeclarationFlags & ModifierFlags.Static) !== (derivedDeclarationFlags & ModifierFlags.Static)) {
|
||||
// value of 'static' is not the same for properties - not override, skip it
|
||||
continue;
|
||||
}
|
||||
@@ -14727,7 +14731,7 @@ namespace ts {
|
||||
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
||||
return;
|
||||
}
|
||||
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
|
||||
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && getModifierFlags(node) !== 0) {
|
||||
grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers);
|
||||
}
|
||||
if (checkExternalImportOrExportDeclaration(node)) {
|
||||
@@ -14757,7 +14761,7 @@ namespace ts {
|
||||
checkGrammarDecorators(node) || checkGrammarModifiers(node);
|
||||
if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
|
||||
checkImportBinding(node);
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (getModifierFlags(node) & ModifierFlags.Export) {
|
||||
markExportAsReferenced(node);
|
||||
}
|
||||
if (isInternalModuleImportEqualsDeclaration(node)) {
|
||||
@@ -14790,7 +14794,7 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
|
||||
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && getModifierFlags(node) !== 0) {
|
||||
grammarErrorOnFirstToken(node, Diagnostics.An_export_declaration_cannot_have_modifiers);
|
||||
}
|
||||
|
||||
@@ -14849,7 +14853,7 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
// Grammar checking
|
||||
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
|
||||
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && getModifierFlags(node) !== 0) {
|
||||
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
|
||||
}
|
||||
if (node.expression.kind === SyntaxKind.Identifier) {
|
||||
@@ -15177,7 +15181,7 @@ namespace ts {
|
||||
|
||||
function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] {
|
||||
const symbols: SymbolTable = {};
|
||||
let memberFlags: NodeFlags = 0;
|
||||
let memberFlags: ModifierFlags = ModifierFlags.None;
|
||||
|
||||
if (isInsideWithStatementBody(location)) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
@@ -15218,7 +15222,7 @@ namespace ts {
|
||||
// add the type parameters into the symbol table
|
||||
// (type parameters of classDeclaration/classExpression and interface are in member property of the symbol.
|
||||
// Note: that the memberFlags come from previous iteration.
|
||||
if (!(memberFlags & NodeFlags.Static)) {
|
||||
if (!(memberFlags & ModifierFlags.Static)) {
|
||||
copySymbols(getSymbolOfNode(location).members, meaning & SymbolFlags.Type);
|
||||
}
|
||||
break;
|
||||
@@ -15234,7 +15238,7 @@ namespace ts {
|
||||
copySymbol(argumentsSymbol, meaning);
|
||||
}
|
||||
|
||||
memberFlags = location.flags;
|
||||
memberFlags = getModifierFlags(location);
|
||||
location = location.parent;
|
||||
}
|
||||
|
||||
@@ -15592,7 +15596,7 @@ namespace ts {
|
||||
*/
|
||||
function getParentTypeOfClassElement(node: ClassElement) {
|
||||
const classSymbol = getSymbolOfNode(node.parent);
|
||||
return node.flags & NodeFlags.Static
|
||||
return getModifierFlags(node) & ModifierFlags.Static
|
||||
? getTypeOfSymbol(classSymbol)
|
||||
: getDeclaredTypeOfSymbol(classSymbol);
|
||||
}
|
||||
@@ -16169,7 +16173,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node, lastAsync: Node, lastReadonly: Node;
|
||||
let flags = 0;
|
||||
let flags = ModifierFlags.None;
|
||||
for (const modifier of node.modifiers) {
|
||||
if (modifier.kind !== SyntaxKind.ReadonlyKeyword) {
|
||||
if (node.kind === SyntaxKind.PropertySignature || node.kind === SyntaxKind.MethodSignature) {
|
||||
@@ -16201,22 +16205,22 @@ namespace ts {
|
||||
lastPrivate = modifier;
|
||||
}
|
||||
|
||||
if (flags & NodeFlags.AccessibilityModifier) {
|
||||
if (flags & ModifierFlags.AccessibilityModifier) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen);
|
||||
}
|
||||
else if (flags & NodeFlags.Static) {
|
||||
else if (flags & ModifierFlags.Static) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
|
||||
}
|
||||
else if (flags & NodeFlags.Readonly) {
|
||||
else if (flags & ModifierFlags.Readonly) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly");
|
||||
}
|
||||
else if (flags & NodeFlags.Async) {
|
||||
else if (flags & ModifierFlags.Async) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
|
||||
}
|
||||
else if (flags & NodeFlags.Abstract) {
|
||||
else if (flags & ModifierFlags.Abstract) {
|
||||
if (modifier.kind === SyntaxKind.PrivateKeyword) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
|
||||
}
|
||||
@@ -16228,13 +16232,13 @@ namespace ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.StaticKeyword:
|
||||
if (flags & NodeFlags.Static) {
|
||||
if (flags & ModifierFlags.Static) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static");
|
||||
}
|
||||
else if (flags & NodeFlags.Readonly) {
|
||||
else if (flags & ModifierFlags.Readonly) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
|
||||
}
|
||||
else if (flags & NodeFlags.Async) {
|
||||
else if (flags & ModifierFlags.Async) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
|
||||
@@ -16243,35 +16247,35 @@ namespace ts {
|
||||
else if (node.kind === SyntaxKind.Parameter) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
|
||||
}
|
||||
else if (flags & NodeFlags.Abstract) {
|
||||
else if (flags & ModifierFlags.Abstract) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
|
||||
}
|
||||
flags |= NodeFlags.Static;
|
||||
flags |= ModifierFlags.Static;
|
||||
lastStatic = modifier;
|
||||
break;
|
||||
|
||||
case SyntaxKind.ReadonlyKeyword:
|
||||
if (flags & NodeFlags.Readonly) {
|
||||
if (flags & ModifierFlags.Readonly) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "readonly");
|
||||
}
|
||||
else if (node.kind !== SyntaxKind.PropertyDeclaration && node.kind !== SyntaxKind.PropertySignature && node.kind !== SyntaxKind.IndexSignature) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
|
||||
}
|
||||
flags |= NodeFlags.Readonly;
|
||||
flags |= ModifierFlags.Readonly;
|
||||
lastReadonly = modifier;
|
||||
break;
|
||||
|
||||
case SyntaxKind.ExportKeyword:
|
||||
if (flags & NodeFlags.Export) {
|
||||
if (flags & ModifierFlags.Export) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "export");
|
||||
}
|
||||
else if (flags & NodeFlags.Ambient) {
|
||||
else if (flags & ModifierFlags.Ambient) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
|
||||
}
|
||||
else if (flags & NodeFlags.Abstract) {
|
||||
else if (flags & ModifierFlags.Abstract) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract");
|
||||
}
|
||||
else if (flags & NodeFlags.Async) {
|
||||
else if (flags & ModifierFlags.Async) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
@@ -16280,14 +16284,14 @@ namespace ts {
|
||||
else if (node.kind === SyntaxKind.Parameter) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
|
||||
}
|
||||
flags |= NodeFlags.Export;
|
||||
flags |= ModifierFlags.Export;
|
||||
break;
|
||||
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
if (flags & NodeFlags.Ambient) {
|
||||
if (flags & ModifierFlags.Ambient) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare");
|
||||
}
|
||||
else if (flags & NodeFlags.Async) {
|
||||
else if (flags & ModifierFlags.Async) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
@@ -16299,76 +16303,76 @@ namespace ts {
|
||||
else if (isInAmbientContext(node.parent) && node.parent.kind === SyntaxKind.ModuleBlock) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
|
||||
}
|
||||
flags |= NodeFlags.Ambient;
|
||||
flags |= ModifierFlags.Ambient;
|
||||
lastDeclare = modifier;
|
||||
break;
|
||||
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
if (flags & NodeFlags.Abstract) {
|
||||
if (flags & ModifierFlags.Abstract) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract");
|
||||
}
|
||||
if (node.kind !== SyntaxKind.ClassDeclaration) {
|
||||
if (node.kind !== SyntaxKind.MethodDeclaration) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration);
|
||||
}
|
||||
if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) {
|
||||
if (!(node.parent.kind === SyntaxKind.ClassDeclaration && getModifierFlags(node.parent) & ModifierFlags.Abstract)) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
|
||||
}
|
||||
if (flags & NodeFlags.Static) {
|
||||
if (flags & ModifierFlags.Static) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
|
||||
}
|
||||
if (flags & NodeFlags.Private) {
|
||||
if (flags & ModifierFlags.Private) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
|
||||
}
|
||||
}
|
||||
|
||||
flags |= NodeFlags.Abstract;
|
||||
flags |= ModifierFlags.Abstract;
|
||||
break;
|
||||
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
if (flags & NodeFlags.Async) {
|
||||
if (flags & ModifierFlags.Async) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "async");
|
||||
}
|
||||
else if (flags & NodeFlags.Ambient || isInAmbientContext(node.parent)) {
|
||||
else if (flags & ModifierFlags.Ambient || isInAmbientContext(node.parent)) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
|
||||
}
|
||||
else if (node.kind === SyntaxKind.Parameter) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
|
||||
}
|
||||
flags |= NodeFlags.Async;
|
||||
flags |= ModifierFlags.Async;
|
||||
lastAsync = modifier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.Constructor) {
|
||||
if (flags & NodeFlags.Static) {
|
||||
if (flags & ModifierFlags.Static) {
|
||||
return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
|
||||
}
|
||||
if (flags & NodeFlags.Abstract) {
|
||||
if (flags & ModifierFlags.Abstract) {
|
||||
return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract");
|
||||
}
|
||||
else if (flags & NodeFlags.Protected) {
|
||||
else if (flags & ModifierFlags.Protected) {
|
||||
return grammarErrorOnNode(lastProtected, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected");
|
||||
}
|
||||
else if (flags & NodeFlags.Private) {
|
||||
else if (flags & ModifierFlags.Private) {
|
||||
return grammarErrorOnNode(lastPrivate, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private");
|
||||
}
|
||||
else if (flags & NodeFlags.Async) {
|
||||
else if (flags & ModifierFlags.Async) {
|
||||
return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
|
||||
}
|
||||
else if (flags & NodeFlags.Readonly) {
|
||||
else if (flags & ModifierFlags.Readonly) {
|
||||
return grammarErrorOnNode(lastReadonly, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && flags & NodeFlags.Ambient) {
|
||||
else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && flags & ModifierFlags.Ambient) {
|
||||
return grammarErrorOnNode(lastDeclare, Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
|
||||
}
|
||||
else if (node.kind === SyntaxKind.Parameter && (flags & NodeFlags.AccessibilityModifier) && isBindingPattern((<ParameterDeclaration>node).name)) {
|
||||
else if (node.kind === SyntaxKind.Parameter && (flags & ModifierFlags.AccessibilityModifier) && isBindingPattern((<ParameterDeclaration>node).name)) {
|
||||
return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_a_binding_pattern);
|
||||
}
|
||||
if (flags & NodeFlags.Async) {
|
||||
if (flags & ModifierFlags.Async) {
|
||||
return checkGrammarAsyncModifier(node, lastAsync);
|
||||
}
|
||||
}
|
||||
@@ -16485,7 +16489,7 @@ namespace ts {
|
||||
if (parameter.dotDotDotToken) {
|
||||
return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.An_index_signature_cannot_have_a_rest_parameter);
|
||||
}
|
||||
if (parameter.flags & NodeFlags.Modifier) {
|
||||
if (getModifierFlags(parameter) !== 0) {
|
||||
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier);
|
||||
}
|
||||
if (parameter.questionToken) {
|
||||
@@ -16832,7 +16836,7 @@ namespace ts {
|
||||
if (parameter.dotDotDotToken) {
|
||||
return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_set_accessor_cannot_have_rest_parameter);
|
||||
}
|
||||
else if (parameter.flags & NodeFlags.Modifier) {
|
||||
else if (getModifierFlags(parameter) !== 0) {
|
||||
return grammarErrorOnNode(accessor.name, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
|
||||
}
|
||||
else if (parameter.questionToken) {
|
||||
@@ -17138,8 +17142,7 @@ namespace ts {
|
||||
node.kind === SyntaxKind.ImportEqualsDeclaration ||
|
||||
node.kind === SyntaxKind.ExportDeclaration ||
|
||||
node.kind === SyntaxKind.ExportAssignment ||
|
||||
(node.flags & NodeFlags.Ambient) ||
|
||||
(node.flags & (NodeFlags.Export | NodeFlags.Default))) {
|
||||
getModifierFlags(node) & (ModifierFlags.Ambient | ModifierFlags.Export | ModifierFlags.Default)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -623,12 +623,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) {
|
||||
@@ -637,21 +638,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 ");
|
||||
}
|
||||
}
|
||||
@@ -660,7 +661,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 ");
|
||||
@@ -698,12 +699,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
function writeImportDeclaration(node: ImportDeclaration) {
|
||||
if (!node.importClause && !(node.flags & NodeFlags.Export)) {
|
||||
if (!node.importClause && !hasModifier(node, ModifierFlags.Export)) {
|
||||
// do not write non-exported import declarations that don't have import clauses
|
||||
return;
|
||||
}
|
||||
emitJsDocComments(node);
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
write("export ");
|
||||
}
|
||||
write("import ");
|
||||
@@ -893,7 +894,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[]) {
|
||||
@@ -943,7 +944,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) {
|
||||
@@ -1018,7 +1019,7 @@ namespace ts {
|
||||
function emitParameterProperties(constructorDeclaration: ConstructorDeclaration) {
|
||||
if (constructorDeclaration) {
|
||||
forEach(constructorDeclaration.parameters, param => {
|
||||
if (param.flags & NodeFlags.AccessibilityModifier) {
|
||||
if (hasModifier(param, ModifierFlags.AccessibilityModifier)) {
|
||||
emitPropertyDeclaration(param);
|
||||
}
|
||||
});
|
||||
@@ -1027,7 +1028,7 @@ namespace ts {
|
||||
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
if (node.flags & NodeFlags.Abstract) {
|
||||
if (hasModifier(node, ModifierFlags.Abstract)) {
|
||||
write("abstract ");
|
||||
}
|
||||
|
||||
@@ -1077,7 +1078,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
emitJsDocComments(node);
|
||||
emitClassMemberDeclarationFlags(node.flags);
|
||||
emitClassMemberDeclarationFlags(getModifierFlags(node));
|
||||
emitVariableDeclaration(<VariableDeclaration>node);
|
||||
write(";");
|
||||
writeLine();
|
||||
@@ -1102,7 +1103,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);
|
||||
}
|
||||
}
|
||||
@@ -1119,7 +1120,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 symbolAccesibilityResult.errorModuleName ?
|
||||
symbolAccesibilityResult.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 :
|
||||
@@ -1230,9 +1231,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) {
|
||||
@@ -1263,7 +1264,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 = symbolAccesibilityResult.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;
|
||||
@@ -1281,7 +1282,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
else {
|
||||
if (accessorWithTypeAnnotation.flags & NodeFlags.Static) {
|
||||
if (hasModifier(accessorWithTypeAnnotation, ModifierFlags.Static)) {
|
||||
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
|
||||
symbolAccesibilityResult.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 :
|
||||
@@ -1317,7 +1318,7 @@ namespace ts {
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.MethodDeclaration) {
|
||||
emitClassMemberDeclarationFlags(node.flags);
|
||||
emitClassMemberDeclarationFlags(getModifierFlags(node));
|
||||
}
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
write("function ");
|
||||
@@ -1347,7 +1348,7 @@ namespace ts {
|
||||
|
||||
if (node.kind === SyntaxKind.IndexSignature) {
|
||||
// Index signature can have readonly modifier
|
||||
emitClassMemberDeclarationFlags(node.flags);
|
||||
emitClassMemberDeclarationFlags(getModifierFlags(node));
|
||||
write("[");
|
||||
}
|
||||
else {
|
||||
@@ -1378,7 +1379,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);
|
||||
}
|
||||
|
||||
@@ -1415,7 +1416,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (node.flags & NodeFlags.Static) {
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
|
||||
symbolAccesibilityResult.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 :
|
||||
@@ -1481,7 +1482,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);
|
||||
}
|
||||
|
||||
@@ -1517,7 +1518,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (node.parent.flags & NodeFlags.Static) {
|
||||
if (hasModifier(node.parent, ModifierFlags.Static)) {
|
||||
return symbolAccesibilityResult.errorModuleName ?
|
||||
symbolAccesibilityResult.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 :
|
||||
|
||||
+39
-39
@@ -2579,7 +2579,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
let current = getRootDeclaration(node).parent;
|
||||
while (current) {
|
||||
if (current.kind === SyntaxKind.SourceFile) {
|
||||
return !isExported || ((getCombinedNodeFlags(node) & NodeFlags.Export) !== 0);
|
||||
return !isExported || ((getCombinedModifierFlags(node) & ModifierFlags.Export) !== 0);
|
||||
}
|
||||
else if (isDeclaration(current)) {
|
||||
return false;
|
||||
@@ -3627,7 +3627,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
|
||||
function emitModuleMemberName(node: Declaration) {
|
||||
emitStart(node.name);
|
||||
if (getCombinedNodeFlags(node) & NodeFlags.Export) {
|
||||
if (getCombinedModifierFlags(node) & ModifierFlags.Export) {
|
||||
const container = getContainingModule(node);
|
||||
if (container) {
|
||||
write(getGeneratedNameForNode(container));
|
||||
@@ -3651,7 +3651,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
|
||||
function emitEs6ExportDefaultCompat(node: Node) {
|
||||
if (node.parent.kind === SyntaxKind.SourceFile) {
|
||||
Debug.assert(!!(node.flags & NodeFlags.Default) || node.kind === SyntaxKind.ExportAssignment);
|
||||
Debug.assert(hasModifier(node, ModifierFlags.Default) || node.kind === SyntaxKind.ExportAssignment);
|
||||
// only allow export default at a source file level
|
||||
if (modulekind === ModuleKind.CommonJS || modulekind === ModuleKind.AMD || modulekind === ModuleKind.UMD) {
|
||||
if (!isEs6Module) {
|
||||
@@ -3670,7 +3670,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
}
|
||||
|
||||
function emitExportMemberAssignment(node: FunctionLikeDeclaration | ClassDeclaration) {
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
writeLine();
|
||||
emitStart(node);
|
||||
|
||||
@@ -3679,7 +3679,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
// emit export default <smth> as
|
||||
// export("default", <smth>)
|
||||
write(`${exportFunctionForFile}("`);
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
if (hasModifier(node, ModifierFlags.Default)) {
|
||||
write("default");
|
||||
}
|
||||
else {
|
||||
@@ -3690,7 +3690,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
write(")");
|
||||
}
|
||||
else {
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
if (hasModifier(node, ModifierFlags.Default)) {
|
||||
emitEs6ExportDefaultCompat(node);
|
||||
if (languageVersion === ScriptTarget.ES3) {
|
||||
write("exports[\"default\"]");
|
||||
@@ -3821,7 +3821,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
// because actual variable declarations are hoisted
|
||||
let canDefineTempVariablesInPlace = false;
|
||||
if (root.kind === SyntaxKind.VariableDeclaration) {
|
||||
const isExported = getCombinedNodeFlags(root) & NodeFlags.Export;
|
||||
const isExported = getCombinedModifierFlags(root) & ModifierFlags.Export;
|
||||
const isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root);
|
||||
canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind;
|
||||
}
|
||||
@@ -4163,7 +4163,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
}
|
||||
|
||||
function isES6ExportedDeclaration(node: Node) {
|
||||
return !!(node.flags & NodeFlags.Export) &&
|
||||
return hasModifier(node, ModifierFlags.Export) &&
|
||||
modulekind === ModuleKind.ES6 &&
|
||||
node.parent.kind === SyntaxKind.SourceFile;
|
||||
}
|
||||
@@ -4171,7 +4171,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
function emitVariableStatement(node: VariableStatement) {
|
||||
let startIsEmitted = false;
|
||||
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (isES6ExportedDeclaration(node)) {
|
||||
// Exported ES6 module member
|
||||
write("export ");
|
||||
@@ -4200,7 +4200,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node: VariableStatement) {
|
||||
// If we're not exporting the variables, there's nothing special here.
|
||||
// Always emit comments for these nodes.
|
||||
if (!(node.flags & NodeFlags.Export)) {
|
||||
if (!hasModifier(node, ModifierFlags.Export)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4408,7 +4408,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
if (!shouldEmitAsArrowFunction(node)) {
|
||||
if (isES6ExportedDeclaration(node)) {
|
||||
write("export ");
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
if (hasModifier(node, ModifierFlags.Default)) {
|
||||
write("default ");
|
||||
}
|
||||
}
|
||||
@@ -4661,7 +4661,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
function emitExpressionFunctionBody(node: FunctionLikeDeclaration, body: Expression) {
|
||||
if (languageVersion < ScriptTarget.ES6 || node.flags & NodeFlags.Async) {
|
||||
if (languageVersion < ScriptTarget.ES6 || hasModifier(node, ModifierFlags.Async)) {
|
||||
emitDownLevelExpressionFunctionBody(node, body);
|
||||
return;
|
||||
}
|
||||
@@ -4777,7 +4777,7 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function emitParameterPropertyAssignments(node: ConstructorDeclaration) {
|
||||
forEach(node.parameters, param => {
|
||||
if (param.flags & NodeFlags.AccessibilityModifier) {
|
||||
if (hasModifier(param, ModifierFlags.AccessibilityModifier)) {
|
||||
writeLine();
|
||||
emitStart(param);
|
||||
emitStart(param.name);
|
||||
@@ -4813,7 +4813,7 @@ const _super = (function (geti, seti) {
|
||||
function getInitializedProperties(node: ClassLikeDeclaration, isStatic: boolean) {
|
||||
const properties: PropertyDeclaration[] = [];
|
||||
for (const member of node.members) {
|
||||
if (member.kind === SyntaxKind.PropertyDeclaration && isStatic === ((member.flags & NodeFlags.Static) !== 0) && (<PropertyDeclaration>member).initializer) {
|
||||
if (member.kind === SyntaxKind.PropertyDeclaration && isStatic === hasModifier(member, ModifierFlags.Static) && (<PropertyDeclaration>member).initializer) {
|
||||
properties.push(<PropertyDeclaration>member);
|
||||
}
|
||||
}
|
||||
@@ -4836,7 +4836,7 @@ const _super = (function (geti, seti) {
|
||||
emit(receiver);
|
||||
}
|
||||
else {
|
||||
if (property.flags & NodeFlags.Static) {
|
||||
if (hasModifier(property, ModifierFlags.Static)) {
|
||||
emitDeclarationName(node);
|
||||
}
|
||||
else {
|
||||
@@ -4938,7 +4938,7 @@ const _super = (function (geti, seti) {
|
||||
writeLine();
|
||||
emitLeadingComments(member);
|
||||
emitStart(member);
|
||||
if (member.flags & NodeFlags.Static) {
|
||||
if (hasModifier(member, ModifierFlags.Static)) {
|
||||
write("static ");
|
||||
}
|
||||
|
||||
@@ -4996,7 +4996,7 @@ const _super = (function (geti, seti) {
|
||||
emitCommentsOnNotEmittedNode(member);
|
||||
}
|
||||
// Check if there is any non-static property assignment
|
||||
if (member.kind === SyntaxKind.PropertyDeclaration && (<PropertyDeclaration>member).initializer && (member.flags & NodeFlags.Static) === 0) {
|
||||
if (member.kind === SyntaxKind.PropertyDeclaration && (<PropertyDeclaration>member).initializer && !hasModifier(member, ModifierFlags.Static)) {
|
||||
hasInstancePropertyWithInitializer = true;
|
||||
}
|
||||
});
|
||||
@@ -5210,7 +5210,7 @@ const _super = (function (geti, seti) {
|
||||
writeLine();
|
||||
}
|
||||
|
||||
if (isES6ExportedDeclaration(node) && !(node.flags & NodeFlags.Default)) {
|
||||
if (isES6ExportedDeclaration(node) && !hasModifier(node, ModifierFlags.Default)) {
|
||||
write("export ");
|
||||
}
|
||||
|
||||
@@ -5224,7 +5224,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
else if (isES6ExportedDeclaration(node)) {
|
||||
write("export ");
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
if (hasModifier(node, ModifierFlags.Default)) {
|
||||
write("default ");
|
||||
}
|
||||
}
|
||||
@@ -5258,7 +5258,7 @@ const _super = (function (geti, seti) {
|
||||
// emit name if
|
||||
// - node has a name
|
||||
// - this is default export with static initializers
|
||||
if (node.name || (node.flags & NodeFlags.Default && (staticProperties.length > 0 || modulekind !== ModuleKind.ES6) && !thisNodeIsDecorated)) {
|
||||
if (node.name || (hasModifier(node, ModifierFlags.Default) && (staticProperties.length > 0 || modulekind !== ModuleKind.ES6) && !thisNodeIsDecorated)) {
|
||||
write(" ");
|
||||
emitDeclarationName(node);
|
||||
}
|
||||
@@ -5307,7 +5307,7 @@ const _super = (function (geti, seti) {
|
||||
emitDecoratorsOfClass(node, decoratedClassAlias);
|
||||
}
|
||||
|
||||
if (!(node.flags & NodeFlags.Export)) {
|
||||
if (!hasModifier(node, ModifierFlags.Export)) {
|
||||
return;
|
||||
}
|
||||
if (modulekind !== ModuleKind.ES6) {
|
||||
@@ -5316,7 +5316,7 @@ const _super = (function (geti, seti) {
|
||||
else {
|
||||
// If this is an exported class, but not on the top level (i.e. on an internal
|
||||
// module), export it
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
if (hasModifier(node, ModifierFlags.Default)) {
|
||||
// if this is a top level default export of decorated class, write the export after the declaration.
|
||||
if (thisNodeIsDecorated) {
|
||||
writeLine();
|
||||
@@ -5439,14 +5439,14 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function emitClassMemberPrefix(node: ClassLikeDeclaration, member: Node) {
|
||||
emitDeclarationName(node);
|
||||
if (!(member.flags & NodeFlags.Static)) {
|
||||
if (!hasModifier(member, ModifierFlags.Static)) {
|
||||
write(".prototype");
|
||||
}
|
||||
}
|
||||
|
||||
function emitDecoratorsOfClass(node: ClassLikeDeclaration, decoratedClassAlias: string) {
|
||||
emitDecoratorsOfMembers(node, /*staticFlag*/ 0);
|
||||
emitDecoratorsOfMembers(node, NodeFlags.Static);
|
||||
emitDecoratorsOfMembers(node, ModifierFlags.Static);
|
||||
emitDecoratorsOfConstructor(node, decoratedClassAlias);
|
||||
}
|
||||
|
||||
@@ -5500,10 +5500,10 @@ const _super = (function (geti, seti) {
|
||||
writeLine();
|
||||
}
|
||||
|
||||
function emitDecoratorsOfMembers(node: ClassLikeDeclaration, staticFlag: NodeFlags) {
|
||||
function emitDecoratorsOfMembers(node: ClassLikeDeclaration, staticFlag: ModifierFlags) {
|
||||
for (const member of node.members) {
|
||||
// only emit members in the correct group
|
||||
if ((member.flags & NodeFlags.Static) !== staticFlag) {
|
||||
if ((getModifierFlags(member) & ModifierFlags.Static) !== staticFlag) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5964,7 +5964,7 @@ const _super = (function (geti, seti) {
|
||||
// do not emit var if variable was already hoisted
|
||||
|
||||
const isES6ExportedEnum = isES6ExportedDeclaration(node);
|
||||
if (!(node.flags & NodeFlags.Export) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, SyntaxKind.EnumDeclaration))) {
|
||||
if (!hasModifier(node, ModifierFlags.Export) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, SyntaxKind.EnumDeclaration))) {
|
||||
emitStart(node);
|
||||
if (isES6ExportedEnum) {
|
||||
write("export ");
|
||||
@@ -5993,7 +5993,7 @@ const _super = (function (geti, seti) {
|
||||
emitModuleMemberName(node);
|
||||
write(" = {}));");
|
||||
emitEnd(node);
|
||||
if (!isES6ExportedDeclaration(node) && node.flags & NodeFlags.Export && !shouldHoistDeclarationInSystemJsModule(node)) {
|
||||
if (!isES6ExportedDeclaration(node) && hasModifier(node, ModifierFlags.Export) && !shouldHoistDeclarationInSystemJsModule(node)) {
|
||||
// do not emit var if variable was already hoisted
|
||||
writeLine();
|
||||
emitStart(node);
|
||||
@@ -6005,7 +6005,7 @@ const _super = (function (geti, seti) {
|
||||
write(";");
|
||||
}
|
||||
if (modulekind !== ModuleKind.ES6 && node.parent === currentSourceFile) {
|
||||
if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) {
|
||||
if (modulekind === ModuleKind.System && hasModifier(node, ModifierFlags.Export)) {
|
||||
// write the call to exporter for enum
|
||||
writeLine();
|
||||
write(`${exportFunctionForFile}("`);
|
||||
@@ -6127,7 +6127,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
write(")(");
|
||||
// write moduleDecl = containingModule.m only if it is not exported es6 module member
|
||||
if ((node.flags & NodeFlags.Export) && !isES6ExportedDeclaration(node)) {
|
||||
if (hasModifier(node, ModifierFlags.Export) && !isES6ExportedDeclaration(node)) {
|
||||
emit(node.name);
|
||||
write(" = ");
|
||||
}
|
||||
@@ -6137,7 +6137,7 @@ const _super = (function (geti, seti) {
|
||||
write(" = {}));");
|
||||
emitEnd(node);
|
||||
if (!isES6ExportedDeclaration(node) && node.name.kind === SyntaxKind.Identifier && node.parent === currentSourceFile) {
|
||||
if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) {
|
||||
if (modulekind === ModuleKind.System && hasModifier(node, ModifierFlags.Export)) {
|
||||
writeLine();
|
||||
write(`${exportFunctionForFile}("`);
|
||||
emitDeclarationName(node);
|
||||
@@ -6249,7 +6249,7 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function emitExternalImportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration) {
|
||||
if (contains(externalImports, node)) {
|
||||
const isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0;
|
||||
const isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && hasModifier(node, ModifierFlags.Export);
|
||||
const namespaceDeclaration = getNamespaceDeclarationNode(node);
|
||||
const varOrConst = (languageVersion <= ScriptTarget.ES5) ? "var " : "const ";
|
||||
|
||||
@@ -6339,7 +6339,7 @@ const _super = (function (geti, seti) {
|
||||
write("export ");
|
||||
write("var ");
|
||||
}
|
||||
else if (!(node.flags & NodeFlags.Export)) {
|
||||
else if (!hasModifier(node, ModifierFlags.Export)) {
|
||||
write("var ");
|
||||
}
|
||||
}
|
||||
@@ -6732,7 +6732,7 @@ const _super = (function (geti, seti) {
|
||||
function writeExportedName(node: Identifier | Declaration): void {
|
||||
// do not record default exports
|
||||
// they are local to module and never overwritten (explicitly skipped) by star export
|
||||
if (node.kind !== SyntaxKind.Identifier && node.flags & NodeFlags.Default) {
|
||||
if (node.kind !== SyntaxKind.Identifier && hasModifier(node, ModifierFlags.Default)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6804,8 +6804,8 @@ const _super = (function (geti, seti) {
|
||||
emit(local);
|
||||
}
|
||||
|
||||
const flags = getCombinedNodeFlags(local.kind === SyntaxKind.Identifier ? local.parent : local);
|
||||
if (flags & NodeFlags.Export) {
|
||||
const flags = getCombinedModifierFlags(local.kind === SyntaxKind.Identifier ? local.parent : local);
|
||||
if (flags & ModifierFlags.Export) {
|
||||
if (!exportedDeclarations) {
|
||||
exportedDeclarations = [];
|
||||
}
|
||||
@@ -6820,7 +6820,7 @@ const _super = (function (geti, seti) {
|
||||
writeLine();
|
||||
emit(f);
|
||||
|
||||
if (f.flags & NodeFlags.Export) {
|
||||
if (hasModifier(f, ModifierFlags.Export)) {
|
||||
if (!exportedDeclarations) {
|
||||
exportedDeclarations = [];
|
||||
}
|
||||
@@ -6832,7 +6832,7 @@ const _super = (function (geti, seti) {
|
||||
return exportedDeclarations;
|
||||
|
||||
function visit(node: Node): void {
|
||||
if (node.flags & NodeFlags.Ambient) {
|
||||
if (hasModifier(node, ModifierFlags.Ambient)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7596,7 +7596,7 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function emitNodeConsideringCommentsOption(node: Node, emitNodeConsideringSourcemap: (node: Node) => void): void {
|
||||
if (node) {
|
||||
if (node.flags & NodeFlags.Ambient) {
|
||||
if (hasModifier(node, ModifierFlags.Ambient)) {
|
||||
return emitCommentsOnNotEmittedNode(node);
|
||||
}
|
||||
|
||||
|
||||
+2
-11
@@ -51,20 +51,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createModifiersArray(elements?: Modifier[], location?: TextRange): ModifiersArray {
|
||||
let flags: NodeFlags;
|
||||
if (elements) {
|
||||
if (isModifiersArray(elements)) {
|
||||
return elements;
|
||||
}
|
||||
|
||||
flags = 0;
|
||||
for (const modifier of elements) {
|
||||
flags |= modifierToFlag(modifier.kind);
|
||||
}
|
||||
}
|
||||
else {
|
||||
elements = [];
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
const array = <ModifiersArray>elements;
|
||||
@@ -78,7 +71,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
array.arrayKind = ArrayKind.ModifiersArray;
|
||||
array.flags = flags;
|
||||
return array;
|
||||
}
|
||||
|
||||
@@ -86,7 +78,6 @@ namespace ts {
|
||||
if (modifiers) {
|
||||
const array = createModifiersArray(modifiers);
|
||||
node.modifiers = array;
|
||||
node.flags |= array.flags;
|
||||
}
|
||||
else {
|
||||
node.modifiers = undefined;
|
||||
@@ -1079,9 +1070,9 @@ namespace ts {
|
||||
thisArg = createThis(/*location*/ callee.expression);
|
||||
target = callee;
|
||||
}
|
||||
else if (isSuperCall(callee)) {
|
||||
else if (callee.kind === SyntaxKind.SuperKeyword) {
|
||||
thisArg = createThis(/*location*/ callee);
|
||||
target = languageVersion < ScriptTarget.ES6 ? createIdentifier("_super", /*location*/ callee) : callee;
|
||||
target = languageVersion < ScriptTarget.ES6 ? createIdentifier("_super", /*location*/ callee) : <PrimaryExpression>callee;
|
||||
}
|
||||
else {
|
||||
switch (callee.kind) {
|
||||
|
||||
+10
-16
@@ -1009,7 +1009,6 @@ namespace ts {
|
||||
array.pos = pos;
|
||||
array.end = pos;
|
||||
array.arrayKind = ArrayKind.ModifiersArray;
|
||||
array.flags = 0;
|
||||
return array;
|
||||
}
|
||||
|
||||
@@ -2021,7 +2020,6 @@ namespace ts {
|
||||
|
||||
function setModifiers(node: Node, modifiers: ModifiersArray) {
|
||||
if (modifiers) {
|
||||
node.flags |= modifiers.flags;
|
||||
node.modifiers = modifiers;
|
||||
}
|
||||
}
|
||||
@@ -2826,7 +2824,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const isAsync = !!(arrowFunction.flags & NodeFlags.Async);
|
||||
const isAsync = !!(getModifierFlags(arrowFunction) & ModifierFlags.Async);
|
||||
|
||||
// If we have an arrow, then try to parse the body. Even if not, try to parse if we
|
||||
// have an opening brace, just in case we're in an error state.
|
||||
@@ -2972,7 +2970,7 @@ namespace ts {
|
||||
function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction {
|
||||
const node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction);
|
||||
setModifiers(node, parseModifiersForArrowFunction());
|
||||
const isAsync = !!(node.flags & NodeFlags.Async);
|
||||
const isAsync = !!(getModifierFlags(node) & ModifierFlags.Async);
|
||||
|
||||
// Arrow functions are never generators.
|
||||
//
|
||||
@@ -4032,7 +4030,7 @@ namespace ts {
|
||||
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
|
||||
const isGenerator = !!node.asteriskToken;
|
||||
const isAsync = !!(node.flags & NodeFlags.Async);
|
||||
const isAsync = !!(getModifierFlags(node) & ModifierFlags.Async);
|
||||
node.name =
|
||||
isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
||||
@@ -4765,9 +4763,9 @@ namespace ts {
|
||||
setModifiers(node, modifiers);
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier();
|
||||
node.name = hasModifier(node, ModifierFlags.Default) ? parseOptionalIdentifier() : parseIdentifier();
|
||||
const isGenerator = !!node.asteriskToken;
|
||||
const isAsync = !!(node.flags & NodeFlags.Async);
|
||||
const isAsync = hasModifier(node, ModifierFlags.Async);
|
||||
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
|
||||
node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected);
|
||||
return addJSDocComment(finishNode(node));
|
||||
@@ -4791,7 +4789,7 @@ namespace ts {
|
||||
method.name = name;
|
||||
method.questionToken = questionToken;
|
||||
const isGenerator = !!asteriskToken;
|
||||
const isAsync = !!(method.flags & NodeFlags.Async);
|
||||
const isAsync = hasModifier(method, ModifierFlags.Async);
|
||||
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method);
|
||||
method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage);
|
||||
return addJSDocComment(finishNode(method));
|
||||
@@ -4814,7 +4812,7 @@ namespace ts {
|
||||
// AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield];
|
||||
//
|
||||
// The checker may still error in the static case to explicitly disallow the yield expression.
|
||||
property.initializer = modifiers && modifiers.flags & NodeFlags.Static
|
||||
property.initializer = hasModifier(property, ModifierFlags.Static)
|
||||
? allowInAnd(parseNonParameterInitializer)
|
||||
: doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.DisallowInContext, parseNonParameterInitializer);
|
||||
|
||||
@@ -4964,7 +4962,6 @@ namespace ts {
|
||||
* In such situations, 'permitInvalidConstAsModifier' should be set to true.
|
||||
*/
|
||||
function parseModifiers(permitInvalidConstAsModifier?: boolean): ModifiersArray {
|
||||
let flags = 0;
|
||||
let modifiers: ModifiersArray;
|
||||
while (true) {
|
||||
const modifierStart = scanner.getStartPos();
|
||||
@@ -4983,7 +4980,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
flags |= modifierToFlag(modifierKind);
|
||||
const modifier = finishNode(createNode(modifierKind, modifierStart));
|
||||
if (!modifiers) {
|
||||
modifiers = createModifiersArray([modifier], modifierStart);
|
||||
@@ -4993,7 +4989,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
if (modifiers) {
|
||||
modifiers.flags = flags;
|
||||
modifiers.end = scanner.getStartPos();
|
||||
}
|
||||
return modifiers;
|
||||
@@ -5007,7 +5002,6 @@ namespace ts {
|
||||
nextToken();
|
||||
const modifier = finishNode(createNode(modifierKind, modifierStart));
|
||||
modifiers = createModifiersArray([modifier], modifierStart);
|
||||
modifiers.flags = modifierToFlag(modifierKind);
|
||||
modifiers.end = scanner.getStartPos();
|
||||
}
|
||||
|
||||
@@ -5223,7 +5217,7 @@ namespace ts {
|
||||
node.flags |= flags;
|
||||
node.name = parseIdentifier();
|
||||
node.body = parseOptional(SyntaxKind.DotToken)
|
||||
? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export | namespaceFlag)
|
||||
? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.NestedNamespace | namespaceFlag)
|
||||
: parseModuleBlock();
|
||||
return finishNode(node);
|
||||
}
|
||||
@@ -5245,7 +5239,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseModuleDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ModuleDeclaration {
|
||||
let flags = modifiers ? modifiers.flags : 0;
|
||||
let flags: NodeFlags = 0;
|
||||
if (token === SyntaxKind.GlobalKeyword) {
|
||||
// global augmentation
|
||||
return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers);
|
||||
@@ -5541,7 +5535,7 @@ namespace ts {
|
||||
|
||||
function setExternalModuleIndicator(sourceFile: SourceFile) {
|
||||
sourceFile.externalModuleIndicator = forEach(sourceFile.statements, node =>
|
||||
node.flags & NodeFlags.Export
|
||||
hasModifier(node, ModifierFlags.Export)
|
||||
|| node.kind === SyntaxKind.ImportEqualsDeclaration && (<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference
|
||||
|| node.kind === SyntaxKind.ImportDeclaration
|
||||
|| node.kind === SyntaxKind.ExportAssignment
|
||||
|
||||
+28
-28
@@ -6,9 +6,6 @@
|
||||
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
const delimiters = createDelimiterMap();
|
||||
const brackets = createBracketsMap();
|
||||
|
||||
// Flags enum to track count of temp variables and a few dedicated names
|
||||
const enum TempFlags {
|
||||
Auto = 0x00000000, // No preferred name
|
||||
@@ -18,6 +15,9 @@ namespace ts {
|
||||
|
||||
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
|
||||
export function printFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult {
|
||||
const delimiters = createDelimiterMap();
|
||||
const brackets = createBracketsMap();
|
||||
|
||||
// emit output for the __extends helper function
|
||||
const extendsHelper = `
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
@@ -2520,36 +2520,36 @@ const _super = (function (geti, seti) {
|
||||
return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = unescapeIdentifier(generateIdentifier(node)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createDelimiterMap() {
|
||||
const delimiters: string[] = [];
|
||||
delimiters[ListFormat.None] = "";
|
||||
delimiters[ListFormat.CommaDelimited] = ",";
|
||||
delimiters[ListFormat.BarDelimited] = " |";
|
||||
delimiters[ListFormat.AmpersandDelimited] = " &";
|
||||
return delimiters;
|
||||
}
|
||||
function createDelimiterMap() {
|
||||
const delimiters: string[] = [];
|
||||
delimiters[ListFormat.None] = "";
|
||||
delimiters[ListFormat.CommaDelimited] = ",";
|
||||
delimiters[ListFormat.BarDelimited] = " |";
|
||||
delimiters[ListFormat.AmpersandDelimited] = " &";
|
||||
return delimiters;
|
||||
}
|
||||
|
||||
function getDelimiter(format: ListFormat) {
|
||||
return delimiters[format & ListFormat.DelimitersMask];
|
||||
}
|
||||
function getDelimiter(format: ListFormat) {
|
||||
return delimiters[format & ListFormat.DelimitersMask];
|
||||
}
|
||||
|
||||
function createBracketsMap() {
|
||||
const brackets: string[][] = [];
|
||||
brackets[ListFormat.Braces] = ["{", "}"];
|
||||
brackets[ListFormat.Parenthesis] = ["(", ")"];
|
||||
brackets[ListFormat.AngleBrackets] = ["<", ">"];
|
||||
brackets[ListFormat.SquareBrackets] = ["[", "]"];
|
||||
return brackets;
|
||||
}
|
||||
function createBracketsMap() {
|
||||
const brackets: string[][] = [];
|
||||
brackets[ListFormat.Braces] = ["{", "}"];
|
||||
brackets[ListFormat.Parenthesis] = ["(", ")"];
|
||||
brackets[ListFormat.AngleBrackets] = ["<", ">"];
|
||||
brackets[ListFormat.SquareBrackets] = ["[", "]"];
|
||||
return brackets;
|
||||
}
|
||||
|
||||
function getOpeningBracket(format: ListFormat) {
|
||||
return brackets[format & ListFormat.BracketsMask][0];
|
||||
}
|
||||
function getOpeningBracket(format: ListFormat) {
|
||||
return brackets[format & ListFormat.BracketsMask][0];
|
||||
}
|
||||
|
||||
function getClosingBracket(format: ListFormat) {
|
||||
return brackets[format & ListFormat.BracketsMask][1];
|
||||
function getClosingBracket(format: ListFormat) {
|
||||
return brackets[format & ListFormat.BracketsMask][1];
|
||||
}
|
||||
}
|
||||
|
||||
const enum ListFormat {
|
||||
|
||||
@@ -1311,7 +1311,7 @@ namespace ts {
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
|
||||
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || isDeclarationFile(file))) {
|
||||
const moduleName = <LiteralExpression>(<ModuleDeclaration>node).name;
|
||||
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
|
||||
// This will happen in two cases:
|
||||
|
||||
@@ -1680,7 +1680,7 @@ namespace ts {
|
||||
function visitSuperKeyword(node: PrimaryExpression): LeftHandSideExpression {
|
||||
return containingNonArrowFunction
|
||||
&& isClassElement(containingNonArrowFunction)
|
||||
&& (containingNonArrowFunction.flags & NodeFlags.Static) === 0
|
||||
&& !hasModifier(containingNonArrowFunction, ModifierFlags.Static)
|
||||
? createPropertyAccess(createIdentifier("_super"), "prototype")
|
||||
: createIdentifier("_super");
|
||||
}
|
||||
@@ -1840,7 +1840,7 @@ namespace ts {
|
||||
|
||||
function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) {
|
||||
const expression = getDeclarationName(node);
|
||||
return member.flags & NodeFlags.Static ? expression : createPropertyAccess(expression, "prototype");
|
||||
return hasModifier(member, ModifierFlags.Static) ? expression : createPropertyAccess(expression, "prototype");
|
||||
}
|
||||
|
||||
function hasSynthesizedDefaultSuperCall(constructor: ConstructorDeclaration, hasExtendsClause: boolean) {
|
||||
|
||||
@@ -291,7 +291,7 @@ namespace ts {
|
||||
if (contains(externalImports, node)) {
|
||||
const statements: Statement[] = [];
|
||||
if (moduleKind !== ModuleKind.AMD) {
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
addNode(statements,
|
||||
createStatement(
|
||||
createExportAssignment(
|
||||
@@ -318,7 +318,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
addNode(statements,
|
||||
createStatement(
|
||||
createExportAssignment(node.name, node.name),
|
||||
@@ -505,7 +505,7 @@ namespace ts {
|
||||
function visitFunctionDeclaration(node: FunctionDeclaration): OneOrMany<Statement> {
|
||||
const statements: Statement[] = [];
|
||||
if (node.name) {
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
addNode(statements,
|
||||
createFunctionDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
@@ -517,7 +517,7 @@ namespace ts {
|
||||
)
|
||||
);
|
||||
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
if (hasModifier(node, ModifierFlags.Default)) {
|
||||
addExportDefault(statements, getSynthesizedClone(node.name), /*location*/ node);
|
||||
}
|
||||
}
|
||||
@@ -528,7 +528,7 @@ namespace ts {
|
||||
addExportMemberAssignments(statements, node.name);
|
||||
}
|
||||
else {
|
||||
Debug.assert((node.flags & NodeFlags.Default) !== 0);
|
||||
Debug.assert(hasModifier(node, ModifierFlags.Default));
|
||||
addExportDefault(statements,
|
||||
createFunctionExpression(
|
||||
/*asteriskToken*/ undefined,
|
||||
@@ -546,7 +546,7 @@ namespace ts {
|
||||
function visitClassDeclaration(node: ClassDeclaration): OneOrMany<Statement> {
|
||||
const statements: Statement[] = [];
|
||||
if (node.name) {
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
addNode(statements,
|
||||
createClassDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
@@ -557,7 +557,7 @@ namespace ts {
|
||||
)
|
||||
);
|
||||
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
if (hasModifier(node, ModifierFlags.Default)) {
|
||||
addExportDefault(statements, getSynthesizedClone(node.name), /*location*/ node);
|
||||
}
|
||||
}
|
||||
@@ -568,7 +568,7 @@ namespace ts {
|
||||
addExportMemberAssignments(statements, node.name);
|
||||
}
|
||||
else {
|
||||
Debug.assert((node.flags & NodeFlags.Default) !== 0);
|
||||
Debug.assert(hasModifier(node, ModifierFlags.Default));
|
||||
addExportDefault(statements,
|
||||
createClassExpression(
|
||||
/*name*/ undefined,
|
||||
|
||||
@@ -542,7 +542,7 @@ namespace ts {
|
||||
* @param node The variable statement to visit.
|
||||
*/
|
||||
function visitVariableStatement(node: VariableStatement): OneOrMany<Statement> {
|
||||
const isExported = (node.flags & NodeFlags.Export) !== 0;
|
||||
const isExported = hasModifier(node, ModifierFlags.Export);
|
||||
const expressions: Expression[] = [];
|
||||
for (const variable of node.declarationList.declarations) {
|
||||
addNode(expressions, transformVariable(variable, isExported));
|
||||
@@ -587,7 +587,7 @@ namespace ts {
|
||||
* @param node The function declaration to visit.
|
||||
*/
|
||||
function visitFunctionDeclaration(node: FunctionDeclaration): Node {
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
// If the function is exported, ensure it has a name and rewrite the function without any export flags.
|
||||
const name = node.name || getGeneratedNameForNode(node);
|
||||
node = createFunctionDeclaration(
|
||||
@@ -601,7 +601,7 @@ namespace ts {
|
||||
// Record a declaration export in the outer module body function.
|
||||
recordExportedFunctionDeclaration(node);
|
||||
|
||||
if ((node.flags & NodeFlags.Default) === 0) {
|
||||
if (!hasModifier(node, ModifierFlags.Default)) {
|
||||
recordExportName(name);
|
||||
}
|
||||
}
|
||||
@@ -640,8 +640,8 @@ namespace ts {
|
||||
);
|
||||
|
||||
// If the class was exported, write a declaration export to the inner module body function.
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if ((node.flags & NodeFlags.Default) === 0) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (!hasModifier(node, ModifierFlags.Default)) {
|
||||
recordExportName(name);
|
||||
}
|
||||
|
||||
@@ -1179,7 +1179,7 @@ namespace ts {
|
||||
*/
|
||||
function createDeclarationExport(node: DeclarationStatement) {
|
||||
const declarationName = getDeclarationName(node);
|
||||
const exportName = node.flags & NodeFlags.Default ? createLiteral("default") : declarationName;
|
||||
const exportName = hasModifier(node, ModifierFlags.Default) ? createLiteral("default") : declarationName;
|
||||
return createExportStatement(exportName, declarationName);
|
||||
}
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace ts {
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitTypeScript(node: Node): Node {
|
||||
if (node.flags & NodeFlags.Ambient) {
|
||||
if (hasModifier(node, ModifierFlags.Ambient)) {
|
||||
// TypeScript ambient declarations are elided.
|
||||
return undefined;
|
||||
}
|
||||
@@ -858,7 +858,7 @@ namespace ts {
|
||||
* @param parameter The parameter node.
|
||||
*/
|
||||
function isParameterWithPropertyAssignment(parameter: ParameterDeclaration) {
|
||||
return parameter.flags & NodeFlags.AccessibilityModifier
|
||||
return hasModifier(parameter, ModifierFlags.AccessibilityModifier)
|
||||
&& isIdentifier(parameter.name);
|
||||
}
|
||||
|
||||
@@ -917,7 +917,7 @@ namespace ts {
|
||||
*/
|
||||
function isInitializedProperty(member: ClassElement, isStatic: boolean) {
|
||||
return member.kind === SyntaxKind.PropertyDeclaration
|
||||
&& isStatic === ((member.flags & NodeFlags.Static) !== 0)
|
||||
&& isStatic === hasModifier(member, ModifierFlags.Static)
|
||||
&& (<PropertyDeclaration>member).initializer !== undefined;
|
||||
}
|
||||
|
||||
@@ -1015,7 +1015,7 @@ namespace ts {
|
||||
*/
|
||||
function isDecoratedClassElement(member: ClassElement, isStatic: boolean) {
|
||||
return nodeOrChildIsDecorated(member)
|
||||
&& isStatic === ((member.flags & NodeFlags.Static) !== 0);
|
||||
&& isStatic === hasModifier(member, ModifierFlags.Static);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1905,7 +1905,7 @@ namespace ts {
|
||||
*/
|
||||
function shouldElideFunctionLikeDeclaration(node: FunctionLikeDeclaration) {
|
||||
return node.body === undefined
|
||||
|| node.flags & (NodeFlags.Abstract | NodeFlags.Ambient);
|
||||
|| hasModifier(node, ModifierFlags.Abstract | ModifierFlags.Ambient);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2534,7 +2534,7 @@ namespace ts {
|
||||
* @param node The node to test.
|
||||
*/
|
||||
function isExported(node: Node) {
|
||||
return (node.flags & NodeFlags.Export) !== 0;
|
||||
return hasModifier(node, ModifierFlags.Export);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2562,7 +2562,7 @@ namespace ts {
|
||||
*/
|
||||
function isNamedExternalModuleExport(node: Node) {
|
||||
return isExternalModuleExport(node)
|
||||
&& (node.flags & NodeFlags.Default) === 0;
|
||||
&& hasModifier(node, ModifierFlags.Default);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2572,7 +2572,7 @@ namespace ts {
|
||||
*/
|
||||
function isDefaultExternalModuleExport(node: Node) {
|
||||
return isExternalModuleExport(node)
|
||||
&& (node.flags & NodeFlags.Default) !== 0;
|
||||
&& hasModifier(node, ModifierFlags.Default);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2624,7 +2624,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) {
|
||||
return member.flags & NodeFlags.Static
|
||||
return hasModifier(member, ModifierFlags.Static)
|
||||
? getDeclarationName(node)
|
||||
: getClassPrototype(node);
|
||||
}
|
||||
|
||||
+22
-15
@@ -373,18 +373,9 @@ namespace ts {
|
||||
|
||||
export const enum NodeFlags {
|
||||
None = 0,
|
||||
Export = 1 << 0, // Declarations
|
||||
Ambient = 1 << 1, // Declarations
|
||||
Public = 1 << 2, // Property/Method
|
||||
Private = 1 << 3, // Property/Method
|
||||
Protected = 1 << 4, // Property/Method
|
||||
Static = 1 << 5, // Property/Method
|
||||
Readonly = 1 << 6, // Property/Method
|
||||
Abstract = 1 << 7, // Class/Method/ConstructSignature
|
||||
Async = 1 << 8, // Property/Method/Function
|
||||
Default = 1 << 9, // Function/Class (export default declaration)
|
||||
Let = 1 << 10, // Variable declaration
|
||||
Const = 1 << 11, // Variable declaration
|
||||
Let = 1 << 0, // Variable declaration
|
||||
Const = 1 << 1, // Variable declaration
|
||||
NestedNamespace = 1 << 2, // Namespace declaration
|
||||
Namespace = 1 << 12, // Namespace declaration
|
||||
ExportContext = 1 << 13, // Export context (initialized by binding)
|
||||
ContainsThis = 1 << 14, // Interface contains references to "this"
|
||||
@@ -404,8 +395,6 @@ namespace ts {
|
||||
ThisNodeOrAnySubNodesHasError = 1 << 28, // If this node or any of its children had an error
|
||||
HasAggregatedChildData = 1 << 29, // If we've computed data from children and cached it in this node
|
||||
|
||||
Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async,
|
||||
AccessibilityModifier = Public | Private | Protected,
|
||||
BlockScoped = Let | Const,
|
||||
|
||||
ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn,
|
||||
@@ -418,6 +407,24 @@ namespace ts {
|
||||
TypeExcludesFlags = YieldContext | AwaitContext,
|
||||
}
|
||||
|
||||
export const enum ModifierFlags {
|
||||
None = 0,
|
||||
Export = 1 << 0, // Declarations
|
||||
Ambient = 1 << 1, // Declarations
|
||||
Public = 1 << 2, // Property/Method
|
||||
Private = 1 << 3, // Property/Method
|
||||
Protected = 1 << 4, // Property/Method
|
||||
Static = 1 << 5, // Property/Method
|
||||
Readonly = 1 << 6, // Property/Method
|
||||
Abstract = 1 << 7, // Class/Method/ConstructSignature
|
||||
Async = 1 << 8, // Property/Method/Function
|
||||
Default = 1 << 9, // Function/Class (export default declaration)
|
||||
Const = 1 << 11, // Variable declaration
|
||||
|
||||
AccessibilityModifier = Public | Private | Protected,
|
||||
NonPublicAccessibilityModifier = Private | Protected,
|
||||
}
|
||||
|
||||
export const enum JsxFlags {
|
||||
None = 0,
|
||||
/** An element from a named property of the JSX.IntrinsicElements interface */
|
||||
@@ -482,7 +489,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface ModifiersArray extends NodeArray<Modifier> {
|
||||
flags: number;
|
||||
// flags: number;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.AbstractKeyword)
|
||||
|
||||
+63
-20
@@ -491,6 +491,25 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function getCombinedModifierFlags(node: Node): ModifierFlags {
|
||||
node = walkUpBindingElementsAndPatterns(node);
|
||||
let flags = getModifierFlags(node);
|
||||
if (node.kind === SyntaxKind.VariableDeclaration) {
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
if (node && node.kind === SyntaxKind.VariableDeclarationList) {
|
||||
flags |= getModifierFlags(node);
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
if (node && node.kind === SyntaxKind.VariableStatement) {
|
||||
flags |= getModifierFlags(node);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
// Returns the node flags for this node and all relevant parent nodes. This is done so that
|
||||
// nodes like variable declarations and binding elements can returned a view of their flags
|
||||
// that includes the modifiers from their container. i.e. flags like export/declare aren't
|
||||
@@ -519,7 +538,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isConst(node: Node): boolean {
|
||||
return !!(getCombinedNodeFlags(node) & NodeFlags.Const);
|
||||
return !!(getCombinedNodeFlags(node) & NodeFlags.Const)
|
||||
|| !!(getCombinedModifierFlags(node) & ModifierFlags.Const);
|
||||
}
|
||||
|
||||
export function isLet(node: Node): boolean {
|
||||
@@ -1390,7 +1410,7 @@ namespace ts {
|
||||
|
||||
export function isInAmbientContext(node: Node): boolean {
|
||||
while (node) {
|
||||
if (node.flags & NodeFlags.Ambient || (node.kind === SyntaxKind.SourceFile && (node as SourceFile).isDeclarationFile)) {
|
||||
if (hasModifier(node, ModifierFlags.Ambient) || (node.kind === SyntaxKind.SourceFile && (node as SourceFile).isDeclarationFile)) {
|
||||
return true;
|
||||
}
|
||||
node = node.parent;
|
||||
@@ -1558,7 +1578,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isAsyncFunctionLike(node: Node): boolean {
|
||||
return isFunctionLike(node) && (node.flags & NodeFlags.Async) !== 0 && !isAccessor(node);
|
||||
return isFunctionLike(node) && hasModifier(node, ModifierFlags.Async) && !isAccessor(node);
|
||||
}
|
||||
|
||||
export function isStringOrNumericLiteral(kind: SyntaxKind): boolean {
|
||||
@@ -1667,10 +1687,12 @@ namespace ts {
|
||||
*/
|
||||
export function cloneEntityName(node: EntityName, parent?: Node): EntityName {
|
||||
const clone = getMutableClone(node);
|
||||
clone.parent = parent;
|
||||
if (isQualifiedName(clone)) {
|
||||
const { left, right } = clone;
|
||||
clone.left = cloneEntityName(left, clone);
|
||||
clone.right = getMutableClone(right);
|
||||
clone.right.parent = clone;
|
||||
}
|
||||
|
||||
return clone;
|
||||
@@ -2301,7 +2323,7 @@ namespace ts {
|
||||
else {
|
||||
forEach(declarations, (member: Declaration) => {
|
||||
if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor)
|
||||
&& (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) {
|
||||
&& hasModifier(member, ModifierFlags.Static) === hasModifier(accessor, ModifierFlags.Static)) {
|
||||
const memberName = getPropertyNameForPropertyNameNode(member.name);
|
||||
const accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
||||
if (memberName === accessorName) {
|
||||
@@ -2534,21 +2556,42 @@ namespace ts {
|
||||
return currentLineIndent;
|
||||
}
|
||||
|
||||
export function modifierToFlag(token: SyntaxKind): NodeFlags {
|
||||
switch (token) {
|
||||
case SyntaxKind.StaticKeyword: return NodeFlags.Static;
|
||||
case SyntaxKind.PublicKeyword: return NodeFlags.Public;
|
||||
case SyntaxKind.ProtectedKeyword: return NodeFlags.Protected;
|
||||
case SyntaxKind.PrivateKeyword: return NodeFlags.Private;
|
||||
case SyntaxKind.AbstractKeyword: return NodeFlags.Abstract;
|
||||
case SyntaxKind.ExportKeyword: return NodeFlags.Export;
|
||||
case SyntaxKind.DeclareKeyword: return NodeFlags.Ambient;
|
||||
case SyntaxKind.ConstKeyword: return NodeFlags.Const;
|
||||
case SyntaxKind.DefaultKeyword: return NodeFlags.Default;
|
||||
case SyntaxKind.AsyncKeyword: return NodeFlags.Async;
|
||||
case SyntaxKind.ReadonlyKeyword: return NodeFlags.Readonly;
|
||||
export function hasModifiers(node: Node) {
|
||||
return getModifierFlags(node) !== ModifierFlags.None;
|
||||
}
|
||||
|
||||
export function hasModifier(node: Node, flags: ModifierFlags) {
|
||||
return (getModifierFlags(node) & flags) != 0;
|
||||
}
|
||||
|
||||
export function getModifierFlags(node: Node): ModifierFlags {
|
||||
let flags = ModifierFlags.None;
|
||||
if (node.modifiers) {
|
||||
for (const modifier of node.modifiers) {
|
||||
flags |= modifierToFlag(modifier.kind);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
if (node.flags & NodeFlags.NestedNamespace) {
|
||||
flags |= ModifierFlags.Export;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
export function modifierToFlag(token: SyntaxKind): ModifierFlags {
|
||||
switch (token) {
|
||||
case SyntaxKind.StaticKeyword: return ModifierFlags.Static;
|
||||
case SyntaxKind.PublicKeyword: return ModifierFlags.Public;
|
||||
case SyntaxKind.ProtectedKeyword: return ModifierFlags.Protected;
|
||||
case SyntaxKind.PrivateKeyword: return ModifierFlags.Private;
|
||||
case SyntaxKind.AbstractKeyword: return ModifierFlags.Abstract;
|
||||
case SyntaxKind.ExportKeyword: return ModifierFlags.Export;
|
||||
case SyntaxKind.DeclareKeyword: return ModifierFlags.Ambient;
|
||||
case SyntaxKind.ConstKeyword: return ModifierFlags.Const;
|
||||
case SyntaxKind.DefaultKeyword: return ModifierFlags.Default;
|
||||
case SyntaxKind.AsyncKeyword: return ModifierFlags.Async;
|
||||
case SyntaxKind.ReadonlyKeyword: return ModifierFlags.Readonly;
|
||||
}
|
||||
return ModifierFlags.None;
|
||||
}
|
||||
|
||||
export function isAssignmentOperator(token: SyntaxKind): boolean {
|
||||
@@ -2608,7 +2651,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getLocalSymbolForExportDefault(symbol: Symbol) {
|
||||
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
|
||||
return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, ModifierFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
|
||||
}
|
||||
|
||||
export function hasJavaScriptFileExtension(fileName: string) {
|
||||
@@ -3673,6 +3716,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean {
|
||||
return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
|
||||
return hasModifier(node, ModifierFlags.AccessibilityModifier) && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-12
@@ -611,17 +611,12 @@ namespace ts {
|
||||
|
||||
const edgeTraversalPath = nodeEdgeTraversalMap[node.kind];
|
||||
if (edgeTraversalPath) {
|
||||
let modifiers: NodeFlags;
|
||||
for (const edge of edgeTraversalPath) {
|
||||
const value = <Node | NodeArray<Node>>node[edge.name];
|
||||
if (value !== undefined) {
|
||||
let visited: Node | NodeArray<Node>;
|
||||
if (isArray(value)) {
|
||||
const visitedArray = visitNodesWorker(value, visitor, edge.test, edge.parenthesize, node, 0, value.length);
|
||||
if (isModifiersArray(visitedArray)) {
|
||||
modifiers = visitedArray.flags;
|
||||
}
|
||||
|
||||
visited = visitedArray;
|
||||
}
|
||||
else {
|
||||
@@ -631,12 +626,6 @@ namespace ts {
|
||||
if (updated !== undefined || visited !== value) {
|
||||
if (updated === undefined) {
|
||||
updated = getMutableClone(node);
|
||||
updated.flags &= ~NodeFlags.Modifier;
|
||||
}
|
||||
|
||||
if (modifiers) {
|
||||
updated.flags |= modifiers;
|
||||
modifiers = undefined;
|
||||
}
|
||||
|
||||
if (visited !== value) {
|
||||
@@ -927,7 +916,7 @@ namespace ts {
|
||||
function aggregateTransformFlagsForSubtree(node: Node): TransformFlags {
|
||||
// We do not transform ambient declarations or types, so there is no need to
|
||||
// recursively aggregate transform flags.
|
||||
if (node.flags & NodeFlags.Ambient || isTypeNode(node)) {
|
||||
if (hasModifier(node, ModifierFlags.Ambient) || isTypeNode(node)) {
|
||||
return <TransformFlags>0;
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ namespace ts.BreakpointResolver {
|
||||
// Breakpoint is possible in variableDeclaration only if there is initialization
|
||||
// or its declaration from 'for of'
|
||||
if (variableDeclaration.initializer ||
|
||||
(variableDeclaration.flags & NodeFlags.Export) ||
|
||||
hasModifier(variableDeclaration, ModifierFlags.Export) ||
|
||||
variableDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement) {
|
||||
return textSpanFromVariableDeclaration(variableDeclaration);
|
||||
}
|
||||
@@ -413,7 +413,7 @@ namespace ts.BreakpointResolver {
|
||||
function canHaveSpanInParameterDeclaration(parameter: ParameterDeclaration): boolean {
|
||||
// Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier
|
||||
return !!parameter.initializer || parameter.dotDotDotToken !== undefined ||
|
||||
!!(parameter.flags & NodeFlags.Public) || !!(parameter.flags & NodeFlags.Private);
|
||||
hasModifier(parameter, ModifierFlags.Public | ModifierFlags.Private);
|
||||
}
|
||||
|
||||
function spanInParameterDeclaration(parameter: ParameterDeclaration): TextSpan {
|
||||
@@ -439,7 +439,7 @@ namespace ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration: FunctionLikeDeclaration) {
|
||||
return !!(functionDeclaration.flags & NodeFlags.Export) ||
|
||||
return hasModifier(functionDeclaration, ModifierFlags.Export) ||
|
||||
(functionDeclaration.parent.kind === SyntaxKind.ClassDeclaration && functionDeclaration.kind !== SyntaxKind.Constructor);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace ts.NavigationBar {
|
||||
|
||||
return topLevelNodes;
|
||||
}
|
||||
|
||||
|
||||
function sortNodes(nodes: Node[]): Node[] {
|
||||
return nodes.slice(0).sort((n1: Declaration, n2: Declaration) => {
|
||||
if (n1.name && n2.name) {
|
||||
@@ -147,7 +147,7 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function addTopLevelNodes(nodes: Node[], topLevelNodes: Node[]): void {
|
||||
nodes = sortNodes(nodes);
|
||||
|
||||
@@ -178,8 +178,8 @@ namespace ts.NavigationBar {
|
||||
|
||||
function isTopLevelFunctionDeclaration(functionDeclaration: FunctionLikeDeclaration) {
|
||||
if (functionDeclaration.kind === SyntaxKind.FunctionDeclaration) {
|
||||
// A function declaration is 'top level' if it contains any function declarations
|
||||
// within it.
|
||||
// A function declaration is 'top level' if it contains any function declarations
|
||||
// within it.
|
||||
if (functionDeclaration.body && functionDeclaration.body.kind === SyntaxKind.Block) {
|
||||
// Proper function declarations can only have identifier names
|
||||
if (forEach((<Block>functionDeclaration.body).statements,
|
||||
@@ -198,7 +198,7 @@ namespace ts.NavigationBar {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getItemsWorker(nodes: Node[], createItem: (n: Node) => ts.NavigationBarItem): ts.NavigationBarItem[] {
|
||||
let items: ts.NavigationBarItem[] = [];
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace ts.NavigationBar {
|
||||
if (isBindingPattern((<ParameterDeclaration>node).name)) {
|
||||
break;
|
||||
}
|
||||
if ((node.flags & NodeFlags.Modifier) === 0) {
|
||||
if (!hasModifiers(node)) {
|
||||
return undefined;
|
||||
}
|
||||
return createItem(node, getTextOfNode((<ParameterDeclaration>node).name), ts.ScriptElementKind.memberVariableElement);
|
||||
@@ -395,19 +395,19 @@ namespace ts.NavigationBar {
|
||||
let result: string[] = [];
|
||||
|
||||
result.push(moduleDeclaration.name.text);
|
||||
|
||||
|
||||
while (moduleDeclaration.body && moduleDeclaration.body.kind === SyntaxKind.ModuleDeclaration) {
|
||||
moduleDeclaration = <ModuleDeclaration>moduleDeclaration.body;
|
||||
|
||||
result.push(moduleDeclaration.name.text);
|
||||
}
|
||||
}
|
||||
|
||||
return result.join(".");
|
||||
}
|
||||
|
||||
function createModuleItem(node: ModuleDeclaration): NavigationBarItem {
|
||||
let moduleName = getModuleName(node);
|
||||
|
||||
|
||||
let childItems = getItemsWorker(getChildNodes((<Block>getInnermostModule(node).body).statements), createChildItem);
|
||||
|
||||
return getNavigationBarItem(moduleName,
|
||||
|
||||
+21
-21
@@ -962,7 +962,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
// Only consider properties defined as constructor parameters
|
||||
if (!(node.flags & NodeFlags.AccessibilityModifier)) {
|
||||
if (!(getModifierFlags(node) & ModifierFlags.AccessibilityModifier)) {
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
@@ -2655,7 +2655,7 @@ namespace ts {
|
||||
case SyntaxKind.Constructor: return ScriptElementKind.constructorImplementationElement;
|
||||
case SyntaxKind.TypeParameter: return ScriptElementKind.typeParameterElement;
|
||||
case SyntaxKind.EnumMember: return ScriptElementKind.variableElement;
|
||||
case SyntaxKind.Parameter: return (node.flags & NodeFlags.AccessibilityModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
|
||||
case SyntaxKind.Parameter: return (getModifierFlags(node) & ModifierFlags.AccessibilityModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ImportClause:
|
||||
@@ -5046,14 +5046,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
const keywords: Node[] = [];
|
||||
const modifierFlag: NodeFlags = getFlagFromModifier(modifier);
|
||||
const modifierFlag: ModifierFlags = getFlagFromModifier(modifier);
|
||||
|
||||
let nodes: Node[];
|
||||
switch (container.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.SourceFile:
|
||||
// Container is either a class declaration or the declaration is a classDeclaration
|
||||
if (modifierFlag & NodeFlags.Abstract) {
|
||||
if (modifierFlag & ModifierFlags.Abstract) {
|
||||
nodes = (<Node[]>(<ClassDeclaration>declaration).members).concat(declaration);
|
||||
}
|
||||
else {
|
||||
@@ -5070,7 +5070,7 @@ namespace ts {
|
||||
|
||||
// If we're an accessibility modifier, we're in an instance member and should search
|
||||
// the constructor's parameter list for instance members as well.
|
||||
if (modifierFlag & NodeFlags.AccessibilityModifier) {
|
||||
if (modifierFlag & ModifierFlags.AccessibilityModifier) {
|
||||
const constructor = forEach((<ClassLikeDeclaration>container).members, member => {
|
||||
return member.kind === SyntaxKind.Constructor && <ConstructorDeclaration>member;
|
||||
});
|
||||
@@ -5079,7 +5079,7 @@ namespace ts {
|
||||
nodes = nodes.concat(constructor.parameters);
|
||||
}
|
||||
}
|
||||
else if (modifierFlag & NodeFlags.Abstract) {
|
||||
else if (modifierFlag & ModifierFlags.Abstract) {
|
||||
nodes = nodes.concat(container);
|
||||
}
|
||||
break;
|
||||
@@ -5088,7 +5088,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
forEach(nodes, node => {
|
||||
if (node.modifiers && node.flags & modifierFlag) {
|
||||
if (getModifierFlags(node) & modifierFlag) {
|
||||
forEach(node.modifiers, child => pushKeywordIf(keywords, child, modifier));
|
||||
}
|
||||
});
|
||||
@@ -5098,19 +5098,19 @@ namespace ts {
|
||||
function getFlagFromModifier(modifier: SyntaxKind) {
|
||||
switch (modifier) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
return NodeFlags.Public;
|
||||
return ModifierFlags.Public;
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
return NodeFlags.Private;
|
||||
return ModifierFlags.Private;
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
return NodeFlags.Protected;
|
||||
return ModifierFlags.Protected;
|
||||
case SyntaxKind.StaticKeyword:
|
||||
return NodeFlags.Static;
|
||||
return ModifierFlags.Static;
|
||||
case SyntaxKind.ExportKeyword:
|
||||
return NodeFlags.Export;
|
||||
return ModifierFlags.Export;
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
return NodeFlags.Ambient;
|
||||
return ModifierFlags.Ambient;
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
return NodeFlags.Abstract;
|
||||
return ModifierFlags.Abstract;
|
||||
default:
|
||||
Debug.fail();
|
||||
}
|
||||
@@ -5564,7 +5564,7 @@ namespace ts {
|
||||
|
||||
// If this is private property or method, the scope is the containing class
|
||||
if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) {
|
||||
const privateDeclaration = forEach(symbol.getDeclarations(), d => (d.flags & NodeFlags.Private) ? d : undefined);
|
||||
const privateDeclaration = forEach(symbol.getDeclarations(), d => (getModifierFlags(d) & ModifierFlags.Private) ? d : undefined);
|
||||
if (privateDeclaration) {
|
||||
return getAncestor(privateDeclaration, SyntaxKind.ClassDeclaration);
|
||||
}
|
||||
@@ -5819,7 +5819,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
// Whether 'super' occurs in a static context within a class.
|
||||
let staticFlag = NodeFlags.Static;
|
||||
let staticFlag = ModifierFlags.Static;
|
||||
|
||||
switch (searchSpaceNode.kind) {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
@@ -5829,7 +5829,7 @@ namespace ts {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
staticFlag &= searchSpaceNode.flags;
|
||||
staticFlag &= getModifierFlags(searchSpaceNode);
|
||||
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
|
||||
break;
|
||||
default:
|
||||
@@ -5854,7 +5854,7 @@ namespace ts {
|
||||
// If we have a 'super' container, we must have an enclosing class.
|
||||
// Now make sure the owning class is the same as the search-space
|
||||
// and has the same static qualifier as the original 'super's owner.
|
||||
if (container && (NodeFlags.Static & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) {
|
||||
if (container && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) {
|
||||
references.push(getReferenceEntryFromNode(node));
|
||||
}
|
||||
});
|
||||
@@ -5867,7 +5867,7 @@ namespace ts {
|
||||
let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false);
|
||||
|
||||
// Whether 'this' occurs in a static context within a class.
|
||||
let staticFlag = NodeFlags.Static;
|
||||
let staticFlag = ModifierFlags.Static;
|
||||
|
||||
switch (searchSpaceNode.kind) {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
@@ -5881,7 +5881,7 @@ namespace ts {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
staticFlag &= searchSpaceNode.flags;
|
||||
staticFlag &= getModifierFlags(searchSpaceNode);
|
||||
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
|
||||
break;
|
||||
case SyntaxKind.SourceFile:
|
||||
@@ -5953,7 +5953,7 @@ namespace ts {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
// Make sure the container belongs to the same class
|
||||
// and has the appropriate static modifier from the original container.
|
||||
if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & NodeFlags.Static) === staticFlag) {
|
||||
if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag) {
|
||||
result.push(getReferenceEntryFromNode(node));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -521,15 +521,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getNodeModifiers(node: Node): string {
|
||||
let flags = getCombinedNodeFlags(node);
|
||||
let flags = getCombinedModifierFlags(node);
|
||||
let result: string[] = [];
|
||||
|
||||
if (flags & NodeFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
|
||||
if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier);
|
||||
if (flags & NodeFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier);
|
||||
if (flags & NodeFlags.Static) result.push(ScriptElementKindModifier.staticModifier);
|
||||
if (flags & NodeFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier);
|
||||
if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
if (flags & ModifierFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
|
||||
if (flags & ModifierFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier);
|
||||
if (flags & ModifierFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier);
|
||||
if (flags & ModifierFlags.Static) result.push(ScriptElementKindModifier.staticModifier);
|
||||
if (flags & ModifierFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier);
|
||||
if (flags & ModifierFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier);
|
||||
|
||||
return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none;
|
||||
@@ -615,7 +615,7 @@ namespace ts {
|
||||
// [a,b,c] from:
|
||||
// [a, b, c] = someExpression;
|
||||
if (node.parent.kind === SyntaxKind.BinaryExpression &&
|
||||
(<BinaryExpression>node.parent).left === node &&
|
||||
(<BinaryExpression>node.parent).left === node &&
|
||||
(<BinaryExpression>node.parent).operatorToken.kind === SyntaxKind.EqualsToken) {
|
||||
return true;
|
||||
}
|
||||
@@ -629,7 +629,7 @@ namespace ts {
|
||||
|
||||
// [a, b, c] of
|
||||
// [x, [a, b, c] ] = someExpression
|
||||
// or
|
||||
// or
|
||||
// {x, a: {a, b, c} } = someExpression
|
||||
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === SyntaxKind.PropertyAssignment ? node.parent.parent : node.parent)) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user