-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf971ab
commit 7a63d89
Showing
7 changed files
with
42 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Need functions from tsutils. | ||
* Copied here so they can be patched if needed. | ||
* Should in future be removed and replaced with a new lib. | ||
* | ||
* @see https://github.com/typescript-eslint/typescript-eslint/issues/5552 | ||
*/ | ||
|
||
import type tsType from "typescript"; | ||
|
||
import ts from "~/conditional-imports/typescript"; | ||
|
||
export function isUnionType(type: tsType.Type): type is tsType.UnionType { | ||
if (ts === undefined) { | ||
return false; | ||
} | ||
return (type.flags & ts.TypeFlags.Union) !== 0; | ||
} | ||
|
||
export function unionTypeParts(type: tsType.Type): tsType.Type[] { | ||
return isUnionType(type) ? type.types : [type]; | ||
} | ||
|
||
export function isIdentifier(node: tsType.Node): node is tsType.Identifier { | ||
if (ts === undefined) { | ||
return false; | ||
} | ||
return node.kind === ts.SyntaxKind.Identifier; | ||
} |