How to use the SyntaxKind function from typescript
Find comprehensive JavaScript typescript.SyntaxKind code examples handpicked from public code repositorys.
400 401 402 403 404 405 406 407 408 409
ts.createExpressionStatement( ts.createCall( ts.createArrowFunction( [ ts.createModifier( ts.SyntaxKind.AsyncKeyword ), ], undefined, [],
116
294
29
+ 13 other calls in file
584 585 586 587 588 589 590 591 592 593
*/ function findUIStringsNode(node) { const nodesToVisit = [node]; while (nodesToVisit.length) { const currentNode = nodesToVisit.shift(); if (currentNode.kind === ts.SyntaxKind.VariableDeclaration && currentNode.name.escapedText === 'UIStrings') { return currentNode; } nodesToVisit.push(...currentNode.getChildren()); }
13
33
7
+ 33 other calls in file
892 893 894 895 896 897 898 899 900 901
if (res !== "any") return res; var type = signature.declaration.type; if (!type) return res; if (type.kind === ts.SyntaxKind.ArrayType) return "Array"; if (!type["typeName"]) return res; var name = type["typeName"].text;
3
4
4
+ 233 other calls in file
61 62 63 64 65 66 67 68 69 70
case typescript_1.SyntaxKind.ImportKeyword: case typescript_1.SyntaxKind.InterfaceKeyword: case typescript_1.SyntaxKind.ModuleKeyword: case typescript_1.SyntaxKind.NamespaceKeyword: case typescript_1.SyntaxKind.SetKeyword: case typescript_1.SyntaxKind.TypeKeyword: return node.getText(sourceFile); } if (!ignoreChildren) { return Utilities_1.default.extractInChildren(node, sourceFile, extractKeyword);
2
4
15
+ 13 other calls in file
GitHub: franzzua/cmmn
46 47 48 49 50 51 52 53 54 55 56
return ts.updateImportDeclaration(importNode, importNode.decorators, importNode.modifiers, importNode.importClause, ts.createStringLiteral(indexFile)); } } function visitRequireNode(importNode, sourceFile) { if (!(importNode.expression.kind == ts.SyntaxKind.Identifier && importNode.expression.escapedText == "require")) { return; } const file = importNode.arguments[0].text;
0
2
1
+ 39 other calls in file
62 63 64 65 66 67 68 69 70 71
return node.getChildren().some(function (element) { return element.kind === ts.SyntaxKind.ObjectLiteralExpression && _this.localizeExpresionSyntaxis(element); }); }; NoFeatureServiceProvidedRootWalker.prototype.localizeExpresionSyntaxis = function (node) { var _this = this; return node.getChildren().some(function (element) { return element.kind === ts.SyntaxKind.SyntaxList && _this.localizeProvideInRoot(element); }); }; NoFeatureServiceProvidedRootWalker.prototype.localizeProvideInRoot = function (node) { return node.getChildren().find(function (element) { return ts.isPropertyAssignment(element) && element.name.getText() === 'providedIn'
1
0
1
+ 5 other calls in file
127 128 129 130 131 132 133 134 135 136
this.checkTypeAnnotation("arrow-call-signature", parameters, type); } }; TypedefWalker.prototype.checkParameter = function (node) { var _a = node, parent = _a.parent, name = _a.name, type = _a.type; var isArrowFunction = parent.kind === ts.SyntaxKind.ArrowFunction; var option = (function () { if (!isArrowFunction) { return "parameter"; }
0
0
1
+ 59 other calls in file
189 190 191 192 193 194 195 196 197 198
} function isAlias(name, initializer) { switch (initializer.kind) { case ts.SyntaxKind.PropertyAccessExpression: return initializer.name.text === name; case ts.SyntaxKind.Identifier: return initializer.text === name; default: return false; }
0
0
1
+ 35 other calls in file
17 18 19 20 21 22 23 24 25 26 27 28 29
/** @typedef {ts.Identifier|ts.BindingName} ExportNameNode */ const RESOLUTION_EXTENSIONS = ['.js', '.json', '.ts', '.tsx', '.d.ts']; /** @param {ts.Statement} node */ const hasExportMod = (node) => node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword); /** @param {string} path */ const safeStat = (path) => { try {
0
0
1
+ 1300 other calls in file
360 361 362 363 364 365 366 367 368 369
return NoUnsafeAnyWalker; }(Lint.AbstractWalker)); /** Check if property has no type annotation in this class and the base class */ function isPropertyAnyOrUnknown(node, checker) { if (!isNodeAny(node.name, checker, true) || node.name.kind === ts.SyntaxKind.ComputedPropertyName) { return false; } for (var _i = 0, _a = checker.getBaseTypes(checker.getTypeAtLocation(node.parent)); _i < _a.length; _i++) { var base = _a[_i];
0
0
1
+ 40501 other calls in file
77 78 79 80 81 82 83 84 85 86
return ts.forEachChild(node, visitNode); }); } var getAsyncModifier = function (node) { if (node.modifiers !== undefined) { return node.modifiers.find(function (modifier) { return modifier.kind === ts.SyntaxKind.AsyncKeyword; }); } return undefined; }; var isReturn = function (node) { return node.kind === ts.SyntaxKind.ReturnKeyword; };
0
0
1
+ 3576 other calls in file
130 131 132 133 134 135 136 137 138 139
return ObjectLiteralKeyQuotesWalker; }(Lint.AbstractWalker)); function mapPropertyName(property) { if (property.kind === ts.SyntaxKind.ShorthandPropertyAssignment || property.kind === ts.SyntaxKind.SpreadAssignment || property.name.kind === ts.SyntaxKind.ComputedPropertyName) { return undefined; } return property.name; }
0
0
1
+ 8869 other calls in file
67 68 69 70 71 72 73 74
var _a; var expression = node.expression; while (tsutils_1.isPropertyAccessExpression(expression) || tsutils_1.isElementAccessExpression(expression)) { (_a = expression, expression = _a.expression); } return expression.kind === ts.SyntaxKind.CallExpression; } var templateObject_1, templateObject_2;
0
0
1
+ 897 other calls in file
43 44 45 46 47 48 49 50 51 52
return Rule; }(Lint.Rules.AbstractRule)); exports.Rule = Rule; function walk(ctx) { return ts.forEachChild(ctx.sourceFile, function cb(node) { if (node.kind === ts.SyntaxKind.NewExpression && node.arguments === undefined) { ctx.addFailureAtNode(node, Rule.FAILURE_STRING); } return ts.forEachChild(node, cb);
0
0
1
+ 916 other calls in file
145 146 147 148 149 150 151 152 153 154
const validReleaseTag = tags.some(tag => releaseTags.includes(tagEscapedText(tag))); if (validReleaseTag) { return true; } else { let name; if (declaration.kind === ts.SyntaxKind.Constructor) name = declaration.parent && declaration.parent.symbol && declaration.parent.symbol.escapedName; else { name = declaration.symbol && declaration.symbol.escapedName; const parentSymbol = getParentSymbolName(declaration);
0
0
2
+ 47 other calls in file
236 237 238 239 240 241 242 243 244 245
const hasNamespaceImport = importNodeTs.importClause && importNodeTs.importClause.namedBindings && importNodeTs.importClause.namedBindings.kind === ts.SyntaxKind.NamespaceImport; // there may be some situations where not reporting this is preferable const isSideEffectImport = !importNodeTs.importClause ||
0
0
2
+ 19 other calls in file
67 68 69 70 71 72 73 74 75 76
const parserServices = getParserServices(context); const allowLineBreaksInside = context.options[0][OPTION_ALLOW_LINE_BREAKS_INSIDE_BRACKETS]; const allowLineBreaks = context.options[0][OPTION_ALLOW_LINE_BREAKS]; function isNamespaceImport(tsNode) { return tsNode.kind === ts.SyntaxKind.NamespaceImport; } function checkModuleWithSideEffect(tsNode) { const nodeStart = tsNode.getStart();
0
0
2
+ 16 other calls in file
523 524 525 526 527 528 529 530 531
); expect(modifiers[0].typeArguments[0].members[0].type.members[0].name.escapedText).toBe( 'enabled' ); expect(modifiers[0].typeArguments[0].members[0].type.members[0].type.kind).toBe( ts.SyntaxKind.TrueKeyword ); }); });
0
0
1
+ 1524 other calls in file
126 127 128 129 130 131 132 133 134 135
if (!checkStrings) { var nodeAtLimit = tsutils_1.getTokenAtPosition(sourceFile, pos + limit); if (nodeAtLimit !== undefined) { shouldOmitLine = shouldOmitLine || nodeAtLimit.kind === ts.SyntaxKind.StringLiteral || nodeAtLimit.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral || hasParentMatchingTypes(nodeAtLimit, sourceFile, [ts.SyntaxKind.TemplateExpression]); } }
0
0
1
+ 1484 other calls in file
94 95 96 97 98 99 100 101 102 103
case ts.SyntaxKind.Parameter: case ts.SyntaxKind.PropertyDeclaration: case ts.SyntaxKind.EnumMember: case ts.SyntaxKind.ImportEqualsDeclaration: return parent.name === identifier; case ts.SyntaxKind.PropertyAssignment: return (parent.name === identifier && !tsutils_1.isReassignmentTarget(identifier.parent.parent)); case ts.SyntaxKind.BindingElement: // return true for `b` in `const {a: b} = obj"`
0
0
1
+ 1439 other calls in file
typescript.SyntaxKind is the most popular function in typescript (82777 examples)