MCPcopy Index your code
hub / github.com/nodejs/node / checkConstEnumAccess

Function checkConstEnumAccess

test/fixtures/snapshot/typescript.js:79869–79889  ·  view source on GitHub ↗
(node, type)

Source from the content-addressed store, hash-verified

79867 return type;
79868 }
79869 function checkConstEnumAccess(node, type) {
79870 // enum object type for const enums are only permitted in:
79871 // - 'left' in property access
79872 // - 'object' in indexed access
79873 // - target in rhs of import statement
79874 var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) ||
79875 (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) ||
79876 ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) ||
79877 (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) ||
79878 (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums
79879 if (!ok) {
79880 error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query);
79881 }
79882 if (compilerOptions.isolatedModules) {
79883 ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */));
79884 var constEnumDeclaration = type.symbol.valueDeclaration;
79885 if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) {
79886 error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
79887 }
79888 }
79889 }
79890 function checkParenthesizedExpression(node, checkMode) {
79891 if (ts.hasJSDocNodes(node) && ts.isJSDocTypeAssertion(node)) {
79892 var type = ts.getJSDocTypeAssertionType(node);

Callers 1

checkExpressionFunction · 0.85

Calls 3

assertMethod · 0.80
errorFunction · 0.70

Tested by

no test coverage detected