It depends on deno_doc v0.6.0+, so it doesn't work with the current latest version of Deno (1.11.2).
To see it working locally, you have to specify the path to the canary or a binary you built on your own from the latest source. In my case, I changed api/docs.ts L27-32 to:
then I ran vercel dev and attempted to generate doc for the following snippet.
export function f1(val1: A | B): val1 is A {}
export function f2(val2: any): asserts val2 is string {}
export function f3(val3: any): asserts val3 {}
export function assertIsDefined<T>(val4: T): asserts val4 is NonNullable<T> {
if (val === undefined || val === null) {
throw new AssertionError(
`Expected 'val' to be defined, but received ${val}`
);
}
}
export class C {
isSomething(): this is Something {
return this instanceof Something;
}
}
export type A = string | number;
This PR adds support for user-defined type guards as return type. Fixes #207 Fixes https://github.com/denoland/deno_doc/issues/102
It depends on deno_doc v0.6.0+, so it doesn't work with the current latest version of Deno (1.11.2). To see it working locally, you have to specify the path to the canary or a binary you built on your own from the latest source. In my case, I changed
api/docs.ts
L27-32 to:then I ran
vercel dev
and attempted to generate doc for the following snippet.Finally, the generated doc looks like:
Ref: https://github.com/denoland/deno_doc/pull/105