type Position = { line : number ; column : number ; } ; type Location = { start : Position ; end : Position ; } ; const isPosition = ( position ) : position is Position => ( typeof position ?. line === 'number' && typeof position ?. column === 'number' ) ; const isSamePosition = ( positionA , positionB ) => ( positionA . line === positionB . line && positionA . column === positionB . column ) ; export const isLocation = ( location ) : location is Location => ( isPosition ( location ?. start ) && isPosition ( location ?. end ) ) ; export const isSameLocation = ( locationA , locationB ) => ( isSamePosition ( locationA . start , locationB . start ) && isSamePosition ( locationA . end , locationB . end ) ) ;