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

Function checkTypeParameters

test/fixtures/snapshot/typescript.js:83956–83981  ·  view source on GitHub ↗

* Check each type parameter and check that type parameters have no duplicate type parameter declarations

(typeParameterDeclarations)

Source from the content-addressed store, hash-verified

83954 * Check each type parameter and check that type parameters have no duplicate type parameter declarations
83955 */
83956 function checkTypeParameters(typeParameterDeclarations) {
83957 var seenDefault = false;
83958 if (typeParameterDeclarations) {
83959 for (var i = 0; i < typeParameterDeclarations.length; i++) {
83960 var node = typeParameterDeclarations[i];
83961 checkTypeParameter(node);
83962 addLazyDiagnostic(createCheckTypeParameterDiagnostic(node, i));
83963 }
83964 }
83965 function createCheckTypeParameterDiagnostic(node, i) {
83966 return function () {
83967 if (node.default) {
83968 seenDefault = true;
83969 checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
83970 }
83971 else if (seenDefault) {
83972 error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
83973 }
83974 for (var j = 0; j < i; j++) {
83975 if (typeParameterDeclarations[j].symbol === node.symbol) {
83976 error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
83977 }
83978 }
83979 };
83980 }
83981 }
83982 /** Check that type parameter defaults only reference previously declared type parameters */
83983 function checkTypeParametersNotReferenced(root, typeParameters, index) {
83984 visit(root);

Callers 5

checkJSDocTypeAliasTagFunction · 0.85

Calls 3

checkTypeParameterFunction · 0.85
addLazyDiagnosticFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…