ts-auto-guard
Advanced tools
Comparing version 1.0.0-alpha.20 to 1.0.0-alpha.21
@@ -436,3 +436,3 @@ "use strict"; | ||
if (debug) { | ||
if (expectedType.startsWith('import')) { | ||
if (expectedType.indexOf('import') > -1) { | ||
expectedType = expectedType.replace(process.cwd(), '.'); | ||
@@ -439,0 +439,0 @@ } |
{ | ||
"name": "ts-auto-guard", | ||
"version": "1.0.0-alpha.20", | ||
"version": "1.0.0-alpha.21", | ||
"description": "Generate type guard functions from TypeScript interfaces", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/rhys-vdw/ts-auto-guard", |
@@ -182,7 +182,8 @@ import { each, pull } from 'lodash' | ||
{ | ||
'test.ts': ` | ||
[`${process.cwd()}/foo/bar/test.ts`]: ` | ||
/** @see {isFoo} ts-auto-guard:type-guard */ | ||
export interface Foo { | ||
foo: number, | ||
bar: Bar | ||
bar: Bar, | ||
bars: Array<Bar> | ||
} | ||
@@ -198,3 +199,3 @@ | ||
{ | ||
'test.guard.ts': ` | ||
[`${process.cwd()}/foo/bar/test.guard.ts`.slice(1)]: ` | ||
import { Foo, Bar } from "./test"; | ||
@@ -223,3 +224,7 @@ | ||
evaluate(typeof obj.foo === "number", \`\${argumentName}.foo\`, "number", obj.foo) && | ||
evaluate(isBar(obj.bar) as boolean, \`\${argumentName}.bar\`, "import(\\"/test\\").Bar", obj.bar) | ||
evaluate(isBar(obj.bar) as boolean, \`\${argumentName}.bar\`, "import(\\"./foo/bar/test\\").Bar", obj.bar) && | ||
evaluate(Array.isArray(obj.bars) && | ||
obj.bars.every((e: any) => | ||
isBar(e) as boolean | ||
), \`\${argumentName}.bars\`, "import(\\"./foo/bar/test\\").Bar[]", obj.bars) | ||
) | ||
@@ -226,0 +231,0 @@ } |
Sorry, the diff of this file is not supported yet
112571
2107