diff --git a/lib/es/Declaration.ts b/lib/es/Declaration.ts index 3fbca7d..611bef5 100644 --- a/lib/es/Declaration.ts +++ b/lib/es/Declaration.ts @@ -7,17 +7,17 @@ export type Interface = (ExportAllDeclaration | ExportNamedDeclaration) | Import export type IOptions = IBaseOptions; export default class Declaration extends Base { - constructor({ declaration, ...rest}: IOptions) { + constructor({ declaration, file, ...rest}: IOptions) { // RAII checks const { type, value } = (declaration.source as SimpleLiteral); if (type !== 'Literal') { - throw new TypeError(`Invalid ES declaration source type: ${type}`); + throw new TypeError(`Invalid ES declaration source type '${type}' in '${file.source}'`); } if (typeof value !== 'string') { - throw new TypeError(`The type of the ES source value was not a 'string': ${typeof value}`); + throw new TypeError(`The type '${typeof value}' of the ES source value was not a 'string' for '${file.source}'`); } - super({declaration, ...rest, path: value}); + super({declaration, file, ...rest, path: value}); } private get literal(): SimpleLiteral { diff --git a/lib/ts/Declaration.ts b/lib/ts/Declaration.ts index cdb21bb..300e192 100644 --- a/lib/ts/Declaration.ts +++ b/lib/ts/Declaration.ts @@ -7,15 +7,17 @@ export type Interface = ExportDeclaration | ImportDeclaration; export type IOptions = IBaseOptions; export default class Declaration extends Base { - constructor({ declaration, ...rest}: IOptions) { - + constructor({ declaration, file, ...rest}: IOptions) { // RAII checks + if (!declaration.moduleSpecifier) { + throw new TypeError(`No TS module specifier in '${file.source}'`); + } const { kind, text } = (declaration.moduleSpecifier as StringLiteral); if (kind !== SyntaxKind.StringLiteral) { - throw new TypeError(`Invalid TS declaration source type: ${kind}`); + throw new TypeError(`Invalid TS declaration literal kind '${kind}' in '${file.source}'`); } - super({declaration, ...rest, path: text}); + super({declaration, file, ...rest, path: text}); } private get literal(): StringLiteral {