Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type aliases produce type guards with TS errors (TS6133) #237

Open
doblinger-extron opened this issue Sep 20, 2023 · 1 comment
Open

Type aliases produce type guards with TS errors (TS6133) #237

doblinger-extron opened this issue Sep 20, 2023 · 1 comment

Comments

@doblinger-extron
Copy link

doblinger-extron commented Sep 20, 2023

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";
}
@rhys-vdw
Copy link
Owner

rhys-vdw commented Oct 3, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants