ts-auto-guard
ts-auto-guard copied to clipboard
Type aliases produce type guards with TS errors (TS6133)
In my project, I'm making use of type aliases for primitives like string
and number
. This results in the following TS compilation error:
'{name}' is declared but its value is never read. ts(6133)
.
Reproduce Steps:
Create two type aliases:
// type1.ts
export type Type1 = string;
// type2.ts
export type Type2 = string;
Output:
import { Type1 } from "./type-1";
export function isType1(obj: unknown): obj is Type1 {
const typedObj = obj as Type1;
return typeof typedObj === "string";
}
// This import is not used, resulting in the ts6133 error
import { isType1 } from "./type-1.type-guard";
import { Type2 } from "./type-2";
export function isType2(obj: unknown): obj is Type2 {
const typedObj = obj as Type2;
return typeof typedObj === "string";
}
Looks related to #189. Open to a PR for this, but I won't be able to fix it myself.
Are you able to disable that unused check on just guard files?