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

Function checkIndexConstraintForIndexSignature

test/fixtures/snapshot/typescript.js:83863–83885  ·  view source on GitHub ↗
(type, checkInfo)

Source from the content-addressed store, hash-verified

83861 }
83862 }
83863 function checkIndexConstraintForIndexSignature(type, checkInfo) {
83864 var declaration = checkInfo.declaration;
83865 var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83866 var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined;
83867 var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83868 var _loop_29 = function (info) {
83869 if (info === checkInfo)
83870 return "continue";
83871 var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83872 // We check only when (a) the check index signature is declared in the containing type, or (b) the applicable index
83873 // signature is declared in the containing type, or (c) the containing type is an interface and no base interface contains
83874 // both index signatures (i.e. the index signatures are declared in separate inherited interfaces).
83875 var errorNode = localCheckDeclaration || localIndexDeclaration ||
83876 (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getIndexInfoOfType(base, checkInfo.keyType) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
83877 if (errorNode && !isTypeAssignableTo(checkInfo.type, info.type)) {
83878 error(errorNode, ts.Diagnostics._0_index_type_1_is_not_assignable_to_2_index_type_3, typeToString(checkInfo.keyType), typeToString(checkInfo.type), typeToString(info.keyType), typeToString(info.type));
83879 }
83880 };
83881 for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83882 var info = indexInfos_10[_i];
83883 _loop_29(info);
83884 }
83885 }
83886 function checkTypeNameIsReserved(name, message) {
83887 // TS 1.0 spec (April 2014): 3.6.1
83888 // The predefined type keywords are reserved and cannot be used as names of user defined types.

Callers 1

checkIndexConstraintsFunction · 0.85

Calls 4

getApplicableIndexInfosFunction · 0.85
getParentOfSymbolFunction · 0.85
getSymbolOfNodeFunction · 0.85
_loop_29Function · 0.85

Tested by

no test coverage detected