utils

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: MIT, MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExcludePaths = []string{"/node_modules/", "bundled:"}

ExcludePaths contains paths that should be excluded from linting

Functions

func CollectAllCallSignatures

func CollectAllCallSignatures(typeChecker *checker.Checker, t *checker.Type) []*checker.Signature

ex. getCallSignaturesOfType

func CollectBindingNames

func CollectBindingNames(nameNode *ast.Node, callback func(ident *ast.Node, name string))

CollectBindingNames recursively extracts all identifier names from a binding pattern (ObjectBindingPattern, ArrayBindingPattern) or plain Identifier. For each identifier found, it calls the callback with the identifier node and its name.

func ComparePaths

func ComparePaths(a string, b string, program *compiler.Program) int

func CreateCompilerHost

func CreateCompilerHost(cwd string, fs vfs.FS) compiler.CompilerHost

func CreateProgram

func CreateProgram(singleThreaded bool, fs vfs.FS, cwd string, tsconfigPath string, host compiler.CompilerHost) (*compiler.Program, error)

func CreateProgramFromOptions

func CreateProgramFromOptions(singleThreaded bool, compilerOptions *core.CompilerOptions, rootFileNames []string, host compiler.CompilerHost) (*compiler.Program, error)

CreateProgramFromOptions creates a program from in-memory compiler options and root file names, without requiring a tsconfig file on disk.

func Every

func Every[T any](slice []T, f func(T) bool) bool

Source: typescript-go/internal/core/core.go

func Filter

func Filter[T any](slice []T, f func(T) bool) []T

Source: typescript-go/internal/core/core.go

func FilterIndex

func FilterIndex[T any](slice []T, f func(T, int, []T) bool) []T

Source: typescript-go/internal/core/core.go

func Flatten

func Flatten[T any](array [][]T) []T

Source: typescript-go/internal/core/core.go

func ForEachComment

func ForEachComment(node *ast.Node, callback func(comment *ast.CommentRange), sourceFile *ast.SourceFile)

Port https://github.com/JoshuaKGoldberg/ts-api-utils/blob/491c0374725a5dd64632405efea101f20ed5451f/src/comments.ts#L37C17-L37C31

Iterates over all comments owned by `node` or its children.

@category Nodes - Other Utilities

@example

declare const node: ts.Node;

forEachComment(node, (fullText, comment) => {
   console.log(`Found comment at position ${comment.pos}: '${fullText}'.`);
});

func ForEachToken

func ForEachToken(node *ast.Node, callback func(token *ast.Node), sourceFile *ast.SourceFile)

Port https://github.com/JoshuaKGoldberg/ts-api-utils/blob/491c0374725a5dd64632405efea101f20ed5451f/src/tokens.ts#L34

Iterates over all tokens of `node`

@category Nodes - Other Utilities

@example

declare const node: ts.Node;

forEachToken(node, (token) => {
	console.log("Found token:", token.getText());
});

@param node The node whose tokens should be visited @param callback Is called for every token contained in `node`

func GetCallSignatures

func GetCallSignatures(typeChecker *checker.Checker, t *checker.Type) []*checker.Signature

func GetChildren

func GetChildren(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node

getChildrenFromNonJSDocNode from github.com/microsoft/typescript-go/internal/ls/utilities.go

func GetCommentsInRange

func GetCommentsInRange(sourceFile *ast.SourceFile, inRange core.TextRange) iter.Seq[ast.CommentRange]

func GetConstrainedTypeAtLocation

func GetConstrainedTypeAtLocation(typeChecker *checker.Checker, node *ast.Node) *checker.Type

func GetConstraintInfo

func GetConstraintInfo(
	typeChecker *checker.Checker,
	t *checker.Type,
) (constraintType *checker.Type, isTypeParameter bool)

*

  • Returns whether the type is a generic and what its constraint is. *
  • If the type is not a generic, `isTypeParameter` will be `false`, and
  • `constraintType` will be the same as the input type. *
  • If the type is a generic, and it is constrained, `isTypeParameter` will be
  • `true`, and `constraintType` will be the constraint type. *
  • If the type is a generic, but it is not constrained, `constraintType` will be
  • `undefined` (rather than an `unknown` type), due to https://github.com/microsoft/TypeScript/issues/60475 *
  • Successor to {@link getConstrainedTypeAtLocation} due to https://github.com/typescript-eslint/typescript-eslint/issues/10438 *
  • This is considered internal since it is unstable for now and may have breaking changes at any time.
  • Use at your own risk. *
  • @internal *

func GetConstructSignatures

func GetConstructSignatures(typeChecker *checker.Checker, t *checker.Type) []*checker.Signature

func GetContextualType

func GetContextualType(
	typeChecker *checker.Checker,
	node *ast.Node,
) *checker.Type

*

  • Returns the contextual type of a given node.
  • Contextual type is the type of the target the node is going into.
  • i.e. the type of a called function's parameter, or the defined type of a variable declaration

func GetDeclaration

func GetDeclaration(
	typeChecker *checker.Checker,
	node *ast.Node,
) *ast.Declaration

*

  • Gets the declaration for the given variable

func GetEnumLiterals

func GetEnumLiterals(t *checker.Type) []*checker.Type

*

  • Retrieve only the Enum literals from a type. for example:
  • - 123 --> []
  • - {} --> []
  • - Fruit.Apple --> [Fruit.Apple]
  • - Fruit.Apple | Vegetable.Lettuce --> [Fruit.Apple, Vegetable.Lettuce]
  • - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit.Apple, Vegetable.Lettuce]
  • - T extends Fruit --> [Fruit]

func GetEnumTypes

func GetEnumTypes(
	typeChecker *checker.Checker,
	t *checker.Type,
) []*checker.Type

*

  • A type can have 0 or more enum types. For example:
  • - 123 --> []
  • - {} --> []
  • - Fruit.Apple --> [Fruit]
  • - Fruit.Apple | Vegetable.Lettuce --> [Fruit, Vegetable]
  • - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit, Vegetable]
  • - T extends Fruit --> [Fruit]

func GetForStatementHeadLoc

func GetForStatementHeadLoc(
	sourceFile *ast.SourceFile,
	node *ast.Node,
) core.TextRange

*

  • Gets the location of the head of the given for statement variant for reporting. *
  • - `for (const foo in bar) expressionOrBlock`
  • ^^^^^^^^^^^^^^^^^^^^^^ *
  • - `for (const foo of bar) expressionOrBlock`
  • ^^^^^^^^^^^^^^^^^^^^^^ *
  • - `for await (const foo of bar) expressionOrBlock`
  • ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
  • - `for (let i = 0; i < 10; i++) expressionOrBlock`
  • ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

func GetHeritageClauses

func GetHeritageClauses(node *ast.Node) *ast.NodeList

func GetNumberIndexType

func GetNumberIndexType(typeChecker *checker.Checker, t *checker.Type) *checker.Type

func GetOptionsMap

func GetOptionsMap(opts any) map[string]interface{}

GetOptionsMap extracts a map[string]interface{} from rule options. It handles both array format [{ option: value }] and direct object format { option: value }.

func GetParentFunctionNode

func GetParentFunctionNode(
	node *ast.Node,
) *ast.Node

func GetPropertyInfo

func GetPropertyInfo(sourceFile *ast.SourceFile, node *ast.Node) (*ast.Node, string)

GetPropertyInfo extracts the property node and formatted property name from a PropertyAccessExpression or ElementAccessExpression. Returns the property node and a formatted string like ".propertyName" or "[index]". Returns (nil, "") if the node is neither a property access nor an element access expression.

Note: When called from ast.KindPropertyAccessExpression or ast.KindElementAccessExpression listeners, the returned property is guaranteed to be non-nil because:

  • PropertyAccessExpression.Name() always returns a valid Identifier node
  • ElementAccessExpression.ArgumentExpression always exists (after SkipParentheses)

The nil return case only applies when called with nodes of other types.

func GetStaticPropertyName

func GetStaticPropertyName(nameNode *ast.Node) (string, bool)

GetStaticPropertyName extracts the static name from a property name node. It handles Identifier, StringLiteral, NumericLiteral, and ComputedPropertyName (with static string, numeric, BigInt, or template literal expressions). Returns the name and whether it's a static (non-computed or statically-computable) name.

func GetThisExpression

func GetThisExpression(
	node *ast.Node,
) *ast.Node

func GetTypeName

func GetTypeName(
	typeChecker *checker.Checker,
	t *checker.Type,
) string

*

  • Get the type name of a given type.
  • @param typeChecker The context sensitive TypeScript TypeChecker.
  • @param type The type to get the name of.

func GetWellKnownSymbolPropertyOfType

func GetWellKnownSymbolPropertyOfType(t *checker.Type, name string, typeChecker *checker.Checker) *ast.Symbol

func HasCommentsInRange

func HasCommentsInRange(sourceFile *ast.SourceFile, inRange core.TextRange) bool

func IncludesModifier

func IncludesModifier(node interface{ Modifiers() *ast.ModifierList }, modifier ast.Kind) bool

func IntersectionTypeParts

func IntersectionTypeParts(t *checker.Type) []*checker.Type

func IsAnyBuiltinSymbolLike

func IsAnyBuiltinSymbolLike(
	program *compiler.Program,
	typeChecker *checker.Checker,
	t *checker.Type,
) bool

func IsArrayMethodCallWithPredicate

func IsArrayMethodCallWithPredicate(
	typeChecker *checker.Checker,
	node *ast.CallExpression,
) bool

func IsBooleanLiteralType

func IsBooleanLiteralType(t *checker.Type) bool

func IsBuiltinSymbolLike

func IsBuiltinSymbolLike(
	program *compiler.Program,
	typeChecker *checker.Checker,
	t *checker.Type,
	symbolNames ...string,
) bool

func IsBuiltinSymbolLikeRecurser

func IsBuiltinSymbolLikeRecurser(
	program *compiler.Program,
	typeChecker *checker.Checker,
	t *checker.Type,
	predicate func(subType *checker.Type) builtinPredicateMatches,
) bool

func IsBuiltinTypeAliasLike

func IsBuiltinTypeAliasLike(
	program *compiler.Program,
	typeChecker *checker.Checker,
	t *checker.Type,
	predicate func(subType *checker.Type) bool,
) bool

func IsCallback

func IsCallback(
	typeChecker *checker.Checker,
	param *ast.Symbol,
	node *ast.Node,
) bool

func IsErrorLike

func IsErrorLike(
	program *compiler.Program,
	typeChecker *checker.Checker,
	t *checker.Type) bool

*

  • @example
  • ```ts
  • class Foo extends Error {}
  • new Foo()
  • // ^ ErrorLike
  • ```

func IsFalseLiteralType

func IsFalseLiteralType(t *checker.Type) bool

func IsFunctionEndReachable

func IsFunctionEndReachable(node *ast.Node) bool

IsFunctionEndReachable checks if a function's end is reachable (can fall through without a return or throw statement). Uses the binder's NodeFlagsHasImplicitReturn flag.

func IsHigherPrecedenceThanAwait

func IsHigherPrecedenceThanAwait(node *ast.Node) bool

func IsInObjectLiteralMethod

func IsInObjectLiteralMethod(functionNode *ast.Node) bool

IsInObjectLiteralMethod checks if a function node is defined as a method in an object literal. This includes both shorthand method syntax ({ methodA() {} }) and property assignment syntax ({ methodA: function() {} }). Returns true if the function is an object literal method.

func IsIntersectionType

func IsIntersectionType(t *checker.Type) bool

func IsIntrinsicErrorType

func IsIntrinsicErrorType(t *checker.Type) bool

func IsIntrinsicType

func IsIntrinsicType(t *checker.Type) bool

func IsIntrinsicVoidType

func IsIntrinsicVoidType(t *checker.Type) bool

func IsObjectType

func IsObjectType(t *checker.Type) bool

func IsParenlessArrowFunction

func IsParenlessArrowFunction(node *ast.Node) bool

func IsPromiseConstructorLike

func IsPromiseConstructorLike(
	program *compiler.Program,
	typeChecker *checker.Checker,
	t *checker.Type,
) bool

*

  • @example
  • ```ts
  • const value = Promise
  • value.reject
  • // ^ PromiseConstructorLike
  • ```

func IsPromiseLike

func IsPromiseLike(
	program *compiler.Program,
	typeChecker *checker.Checker,
	t *checker.Type) bool

*

  • @example
  • ```ts
  • class DerivedClass extends Promise<number> {}
  • DerivedClass.reject
  • // ^ PromiseLike
  • ```

func IsReadonlyErrorLike

func IsReadonlyErrorLike(
	program *compiler.Program,
	typeChecker *checker.Checker,
	t *checker.Type,
) bool

*

  • @example
  • ```ts
  • type T = Readonly<Error>
  • // ^ ReadonlyErrorLike
  • ```

func IsReadonlyTypeLike

func IsReadonlyTypeLike(
	program *compiler.Program,
	typeChecker *checker.Checker,
	t *checker.Type,
	predicate func(subType *checker.Type) bool,
) bool

*

  • @example
  • ```ts
  • type T = Readonly<{ foo: 'bar' }>
  • // ^ ReadonlyTypeLike
  • ```

func IsRestParameterDeclaration

func IsRestParameterDeclaration(decl *ast.Declaration) bool

func IsSourceFileDefaultLibrary

func IsSourceFileDefaultLibrary(program *compiler.Program, file *ast.SourceFile) bool

func IsStrictCompilerOptionEnabled

func IsStrictCompilerOptionEnabled(
	options *core.CompilerOptions,
	option core.Tristate,
) bool

Checks if a given compiler option is enabled, accounting for whether all flags (except `strictPropertyInitialization`) have been enabled by `strict: true`.

@category Compiler Options

@example

const optionsLenient = {
	noImplicitAny: true,
};

isStrictCompilerOptionEnabled(optionsLenient, "noImplicitAny"); // true isStrictCompilerOptionEnabled(optionsLenient, "noImplicitThis"); // false

@example

const optionsStrict = {
	noImplicitThis: false,
	strict: true,
};

isStrictCompilerOptionEnabled(optionsStrict, "noImplicitAny"); // true isStrictCompilerOptionEnabled(optionsStrict, "noImplicitThis"); // false

func IsStrongPrecedenceNode

func IsStrongPrecedenceNode(innerNode *ast.Node) bool

func IsSymbolFlagSet

func IsSymbolFlagSet(symbol *ast.Symbol, flag ast.SymbolFlags) bool

func IsSymbolFromDefaultLibrary

func IsSymbolFromDefaultLibrary(
	program *compiler.Program,
	symbol *ast.Symbol,
) bool

func IsThenableType

func IsThenableType(
	typeChecker *checker.Checker,
	node *ast.Node,
	t *checker.Type,
) bool

TODO(note): why there is no IntersectionTypeParts

func IsTrueLiteralType

func IsTrueLiteralType(t *checker.Type) bool

func IsTypeAnyArrayType

func IsTypeAnyArrayType(
	t *checker.Type,
	typeChecker *checker.Checker,
) bool

*

  • @returns true if the type is `any[]`

func IsTypeAnyType

func IsTypeAnyType(t *checker.Type) bool

func IsTypeFlagSet

func IsTypeFlagSet(t *checker.Type, flags checker.TypeFlags) bool

func IsTypeParameter

func IsTypeParameter(t *checker.Type) bool

func IsTypeUnknownArrayType

func IsTypeUnknownArrayType(
	t *checker.Type,
	typeChecker *checker.Checker,
) bool

*

  • @returns true if the type is `unknown[]`

func IsTypeUnknownType

func IsTypeUnknownType(t *checker.Type) bool

func IsUnionType

func IsUnionType(t *checker.Type) bool

func IsUnsafeAssignment

func IsUnsafeAssignment(
	t *checker.Type,
	receiverT *checker.Type,
	typeChecker *checker.Checker,
	senderNode *ast.Node,
) (receiver *checker.Type, sender *checker.Type, unsafe bool)

*

  • Does a simple check to see if there is an any being assigned to a non-any type. *
  • This also checks generic positions to ensure there's no unsafe sub-assignments.
  • Note: in the case of generic positions, it makes the assumption that the two types are the same. *
  • @example See tests for examples *
  • @returns false if it's safe, or an object with the two types if it's unsafe

func Map

func Map[T, U any](slice []T, f func(T) U) []U

Source: typescript-go/internal/core/core.go

func Must

func Must[T any](v T, err error) T

func NewOverlayVFS

func NewOverlayVFS(baseFS vfs.FS, virtualFiles map[string]string) vfs.FS

func NewOverlayVFSForFile

func NewOverlayVFSForFile(filePath string, source string) vfs.FS

func NormalizeBigIntLiteral

func NormalizeBigIntLiteral(text string) string

NormalizeBigIntLiteral normalizes a BigInt literal to its decimal string representation, matching ESLint's String(node.value) behavior. e.g., "1n" -> "1", "0x1n" -> "1", "0o1n" -> "1", "0b1n" -> "1"

func NormalizeNumericLiteral

func NormalizeNumericLiteral(text string) string

NormalizeNumericLiteral parses a numeric literal text and returns its normalized string representation, matching ESLint's String(node.value) behavior. e.g., "0x1" -> "1", "1.0" -> "1", "1e2" -> "100"

func ParseJSONC

func ParseJSONC(data []byte, v interface{}) error

ParseJSONC parses JSONC (JSON with Comments) using hujson library

func Ref

func Ref[T any](a T) *T

SUPER DIRTY HACK FOR OPTIONAL FIELDS :(

func Some

func Some[T any](slice []T, f func(T) bool) bool

Source: typescript-go/internal/core/core.go

func StripJSONComments

func StripJSONComments(jsoncString string) string

StripJSONComments removes comments from JSONC and returns clean JSON string

func TrimNodeTextRange

func TrimNodeTextRange(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange

func TypeMatchesSomeSpecifier

func TypeMatchesSomeSpecifier(
	t *checker.Type,
	specifiers []TypeOrValueSpecifier,
	inlineSpecifiers []string,
	program *compiler.Program,
) bool

func TypeMatchesSomeSpecifierWithCalleeNames

func TypeMatchesSomeSpecifierWithCalleeNames(
	t *checker.Type,
	specifiers []TypeOrValueSpecifier,
	inlineSpecifiers []string,
	program *compiler.Program,
	calleeNames []string,
) bool

TypeMatchesSomeSpecifierWithCalleeNames is like TypeMatchesSomeSpecifier but also accepts callee names for matching export aliases (e.g., `export { test as it }` where the type's symbol name is "test" but the callee identifier is "it")

func TypeRecurser

func TypeRecurser(t *checker.Type, predicate func(t *checker.Type) bool) bool

func UnionTypeParts

func UnionTypeParts(t *checker.Type) []*checker.Type

Types

type ConstraintTypeInfo

type ConstraintTypeInfo struct {
	ConstraintType  *checker.Type
	IsTypeParameter bool
}

type DiscriminatedAnyType

type DiscriminatedAnyType uint8
const (
	DiscriminatedAnyTypeAny DiscriminatedAnyType = iota
	DiscriminatedAnyTypePromiseAny
	DiscriminatedAnyTypeAnyArray
	DiscriminatedAnyTypeSafe
)

func DiscriminateAnyType

func DiscriminateAnyType(
	t *checker.Type,
	typeChecker *checker.Checker,
	program *compiler.Program,
	node *ast.Node,
) DiscriminatedAnyType

*

  • @returns `DiscriminatedAnyTypeAny ` if the type is `any`, `DiscriminatedAnyTypeAnyArray` if the type is `any[]` or `readonly any[]`, `DiscriminatedAnyTypePromiseAny` if the type is `Promise<any>`,

* otherwise it returns `DiscriminatedAnyTypeSafe`.

type FunctionReturnAnalysis

type FunctionReturnAnalysis struct {
	EndReachable       bool // Whether the function's end is reachable (can fall through without return/throw)
	HasReturnWithValue bool // Whether any return statement returns a value
	HasEmptyReturn     bool // Whether any return statement is empty (return;)
}

FunctionReturnAnalysis holds the result of analyzing return behavior of a function.

func AnalyzeFunctionReturns

func AnalyzeFunctionReturns(node *ast.Node) FunctionReturnAnalysis

AnalyzeFunctionReturns analyzes a function node's return behavior using the binder's control flow graph and ForEachReturnStatement. The node must be a function-like node (FunctionDeclaration, FunctionExpression, ArrowFunction, Constructor, MethodDeclaration, GetAccessor, SetAccessor).

The binder sets EndFlowNode on function bodies only when the function end is reachable (i.e., some code path falls through without returning or throwing). If EndFlowNode is nil and the body is present, all paths return or throw.

type MemberNameType

type MemberNameType uint8
const (
	MemberNameTypePrivate MemberNameType = iota
	MemberNameTypeQuoted
	MemberNameTypeNormal
	MemberNameTypeExpression
)

func GetNameFromMember

func GetNameFromMember(sourceFile *ast.SourceFile, member *ast.Node) (string, MemberNameType)

*

  • Gets a string name representation of the name of the given MethodDefinition
  • or PropertyDefinition node, with handling for computed property names.

type NameList

type NameList []string

func (*NameList) UnmarshalJSON

func (s *NameList) UnmarshalJSON(data []byte) error

unmarshal a string or a list of strings to NameList

type OverlayVFS

type OverlayVFS struct {
	VirtualFiles map[string]string
	// contains filtered or unexported fields
}

func (*OverlayVFS) Chtimes

func (vfs *OverlayVFS) Chtimes(path string, atime time.Time, mtime time.Time) error

func (*OverlayVFS) DirectoryExists

func (vfs *OverlayVFS) DirectoryExists(path string) bool

func (*OverlayVFS) FileExists

func (vfs *OverlayVFS) FileExists(path string) bool

func (*OverlayVFS) GetAccessibleEntries

func (vfs *OverlayVFS) GetAccessibleEntries(path string) (result vfs.Entries)

func (*OverlayVFS) ReadFile

func (vfs *OverlayVFS) ReadFile(path string) (contents string, ok bool)

func (*OverlayVFS) Realpath

func (vfs *OverlayVFS) Realpath(path string) string

func (*OverlayVFS) Remove

func (vfs *OverlayVFS) Remove(path string) error

func (*OverlayVFS) Stat

func (vfs *OverlayVFS) Stat(path string) vfs.FileInfo

func (*OverlayVFS) UseCaseSensitiveFileNames

func (vfs *OverlayVFS) UseCaseSensitiveFileNames() bool

func (*OverlayVFS) WalkDir

func (vfs *OverlayVFS) WalkDir(root string, walkFn vfs.WalkDirFunc) error

func (*OverlayVFS) WriteFile

func (vfs *OverlayVFS) WriteFile(path string, data string) error

type Set

type Set[T comparable] struct {
	M map[T]struct{}
}

func NewSetFromItems

func NewSetFromItems[T comparable](items ...T) *Set[T]

func NewSetWithSizeHint

func NewSetWithSizeHint[T comparable](hint int) *Set[T]

NewSetWithSizeHint creates a new Set with a hint for the number of elements it will contain.

func (*Set[T]) Add

func (s *Set[T]) Add(key T)

func (*Set[T]) Clear

func (s *Set[T]) Clear()

func (*Set[T]) Delete

func (s *Set[T]) Delete(key T)

func (*Set[T]) Has

func (s *Set[T]) Has(key T) bool

func (*Set[T]) Keys

func (s *Set[T]) Keys() map[T]struct{}

func (*Set[T]) Len

func (s *Set[T]) Len() int

type SyntacticError

type SyntacticError struct {
	Diagnostics []*ast.Diagnostic
	// contains filtered or unexported fields
}

SyntacticError carries structured diagnostics for syntax errors. Callers can type-assert to access the raw diagnostics for rich rendering.

func (*SyntacticError) Error

func (e *SyntacticError) Error() string

type TypeAwaitable

type TypeAwaitable int32
const (
	TypeAwaitableAlways TypeAwaitable = iota
	TypeAwaitableNever
	TypeAwaitableMay
)

func NeedsToBeAwaited

func NeedsToBeAwaited(
	typeChecker *checker.Checker,
	node *ast.Node,
	t *checker.Type,
) TypeAwaitable

type TypeOrValueSpecifier

type TypeOrValueSpecifier struct {
	From TypeOrValueSpecifierFrom `json:"from"`
	Name NameList                 `json:"name"`
	// Can be used when From == TypeOrValueSpecifierFromFile
	Path string `json:"path"`
	// Can be used when From == TypeOrValueSpecifierFromPackage
	Package string `json:"package"`
}

func (*TypeOrValueSpecifier) UnmarshalJSON

func (s *TypeOrValueSpecifier) UnmarshalJSON(data []byte) error

UnmarshalJSON handles both string shorthand ("Promise") and object form ({"from": "lib", "name": "Promise"}) for TypeOrValueSpecifier, matching the original TypeScript-ESLint TypeOrValueSpecifier union type.

type TypeOrValueSpecifierFrom

type TypeOrValueSpecifierFrom uint8
const (
	TypeOrValueSpecifierFromFile TypeOrValueSpecifierFrom = iota
	TypeOrValueSpecifierFromLib
	TypeOrValueSpecifierFromPackage
	// TypeOrValueSpecifierFromString represents the string shorthand form.
	// It matches any type with the given name regardless of origin.
	TypeOrValueSpecifierFromString
)

func (*TypeOrValueSpecifierFrom) UnmarshalJSON

func (s *TypeOrValueSpecifierFrom) UnmarshalJSON(data []byte) error

unmarshal TypeOrValueSpecifierFrom from JSON string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL