import ts from 'typescript' ; import * as utils from '../utils' ; import { getSyntaxKindName } from './syntaxKind' ; type HeritageClausableNode = ts . Node & { readonly heritageClauses ? : ts . NodeArray < ts . HeritageClause > ; } ; export function getHeritageClauses ( node ) { const heritageClauses = utils . getValueOrUndefined ( node . heritageClauses ) ; if ( heritageClauses === undefined ) { return [ ] ; } return heritageClauses ; } export function getHeritageClauseByKind ( node , kind ) { return getHeritageClauses ( node ) . find ( ( clause ) => clause . token === kind ) ; } export function getHeritageClauseByKindOrThrow ( node , kind ) { return utils . throwIfNullOrUndefined ( getHeritageClauseByKind ( node , kind ) , `heritage clause of kind ${ getSyntaxKindName ( kind ) }` ) ; } export function getTypeNodes ( node ) { const types = utils . getValueOrUndefined ( node . types ) ; return types === undefined ? [ ] : types ; } export function getToken ( node ) { return node . token ; } export function isExtends ( node ) { return getToken ( node ) === ts . SyntaxKind . ExtendsKeyword ; } export function isImplements ( node ) { return getToken ( node ) === ts . SyntaxKind . ImplementsKeyword ; }