@@ -347,26 +347,35 @@ export declare function Memoize(target: any, propertyName: string, descriptor: T
347347
348348/** Collection of helper functions that can be used to throw errors. */
349349export declare namespace errors {
350+ /**
351+ * Minimal attributes to show a error message with the node source.
352+ */
353+ interface Node {
354+ getSourceFile ( ) : {
355+ getFilePath ( ) : StandardizedFilePath ;
356+ getFullText ( ) : string ;
357+ } ;
358+ getStart ( ) : number ;
359+ }
350360 /** Base error class. */
351361 abstract class BaseError extends Error {
352- readonly message : string ;
353362 protected constructor ( ) ;
354363 }
355364 /** Thrown when there is a problem with a provided argument. */
356365 class ArgumentError extends BaseError {
357- constructor ( argName : string , message : string ) ;
366+ constructor ( argName : string , message : string , node ?: Node ) ;
358367 }
359368 /** Thrown when an argument is null or whitespace. */
360369 class ArgumentNullOrWhitespaceError extends ArgumentError {
361- constructor ( argName : string ) ;
370+ constructor ( argName : string , node ?: Node ) ;
362371 }
363372 /** Thrown when an argument is out of range. */
364373 class ArgumentOutOfRangeError extends ArgumentError {
365- constructor ( argName : string , value : number , range : [ number , number ] ) ;
374+ constructor ( argName : string , value : number , range : [ number , number ] , node ?: Node ) ;
366375 }
367376 /** Thrown when an argument does not match an expected type. */
368377 class ArgumentTypeError extends ArgumentError {
369- constructor ( argName : string , expectedType : string , actualType : string ) ;
378+ constructor ( argName : string , expectedType : string , actualType : string , node ?: Node ) ;
370379 }
371380 /** Thrown when a file or directory path was not found. */
372381 class PathNotFoundError extends BaseError {
@@ -384,11 +393,11 @@ export declare namespace errors {
384393 }
385394 /** Thrown when an action was taken that is not allowed. */
386395 class InvalidOperationError extends BaseError {
387- constructor ( message : string ) ;
396+ constructor ( message : string , node ?: Node ) ;
388397 }
389398 /** Thrown when a certain behaviour or feature has not been implemented. */
390399 class NotImplementedError extends BaseError {
391- constructor ( message ?: string ) ;
400+ constructor ( message ?: string , node ?: Node ) ;
392401 }
393402 /** Thrown when an operation is not supported. */
394403 class NotSupportedError extends BaseError {
@@ -433,7 +442,7 @@ export declare namespace errors {
433442 * Gets an error saying that a feature is not implemented for a certain syntax kind.
434443 * @param kind - Syntax kind that isn't implemented.
435444 */
436- function throwNotImplementedForSyntaxKindError ( kind : ts . SyntaxKind ) : never ;
445+ function throwNotImplementedForSyntaxKindError ( kind : ts . SyntaxKind , node ?: Node ) : never ;
437446 /**
438447 * Throws an Argument
439448 * @param value
@@ -445,12 +454,12 @@ export declare namespace errors {
445454 * @param value - Value to check.
446455 * @param errorMessage - Error message to throw when not defined.
447456 */
448- function throwIfNullOrUndefined < T > ( value : T | undefined , errorMessage : string | ( ( ) => string ) ) : T ;
457+ function throwIfNullOrUndefined < T > ( value : T | undefined , errorMessage : string | ( ( ) => string ) , node ?: Node ) : T ;
449458 /**
450459 * Throw if the value should have been the never type.
451460 * @param value - Value to check.
452461 */
453- function throwNotImplementedForNeverValueError ( value : never ) : never ;
462+ function throwNotImplementedForNeverValueError ( value : never , sourceNode ?: Node ) : never ;
454463 /**
455464 * Throws an error if the actual value does not equal the expected value.
456465 * @param actual - Actual value.
0 commit comments