diff --git a/src/index.ts b/src/index.ts index 568af76..4e5cdbd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,12 @@ import type { MatchIt } from './matcher' import type { ParseIt } from './parser' -export type Parse = ParseIt -export type Match = MatchIt< - Selector, +export type Parse = ParseIt +export type Match = MatchIt< + SelectorAST, AST > +export type Query< + Selector extends string, + AST extends { type: string }, +> = Match, AST> diff --git a/tests/ecosystem/tests/eslint-stylistic.matcher.generated-test.ts b/tests/ecosystem/tests/eslint-stylistic.matcher.generated-test.ts index e89eb59..aa3afaf 100644 --- a/tests/ecosystem/tests/eslint-stylistic.matcher.generated-test.ts +++ b/tests/ecosystem/tests/eslint-stylistic.matcher.generated-test.ts @@ -1,8 +1,8 @@ -import type { Match as MatchIt, Parse as ParseIt } from "../../../src/index" +import type { Query } from "../../../src/index" import type { Equal, Expect } from "../../../src/utils" import type { TSESTree as T } from '@typescript-eslint/typescript-estree' -type Match<_T extends string> = MatchIt, T.Node> +type Match<_T extends string> = Query<_T, T.Node> export type TestCases = [ Expect, T.Node>>, diff --git a/tests/ecosystem/tests/jest.matcher.generated-test.ts b/tests/ecosystem/tests/jest.matcher.generated-test.ts index 7e9912d..40a8efc 100644 --- a/tests/ecosystem/tests/jest.matcher.generated-test.ts +++ b/tests/ecosystem/tests/jest.matcher.generated-test.ts @@ -1,8 +1,8 @@ -import type { Match as MatchIt, Parse as ParseIt } from "../../../src/index" +import type { Query } from "../../../src/index" import type { Equal, Expect } from "../../../src/utils" import type { TSESTree as T } from '@typescript-eslint/typescript-estree' -type Match<_T extends string> = MatchIt, T.Node> +type Match<_T extends string> = Query<_T, T.Node> export type TestCases = [ Expect, T.ArrowFunctionExpression>>, diff --git a/tests/ecosystem/tests/ts-eslint.matcher.generated-test.ts b/tests/ecosystem/tests/ts-eslint.matcher.generated-test.ts index e831812..9d9d655 100644 --- a/tests/ecosystem/tests/ts-eslint.matcher.generated-test.ts +++ b/tests/ecosystem/tests/ts-eslint.matcher.generated-test.ts @@ -1,8 +1,8 @@ -import type { Match as MatchIt, Parse as ParseIt } from "../../../src/index" +import type { Query } from "../../../src/index" import type { Equal, Expect } from "../../../src/utils" import type { TSESTree as T } from '@typescript-eslint/typescript-estree' -type Match<_T extends string> = MatchIt, T.Node> +type Match<_T extends string> = Query<_T, T.Node> export type TestCases = [ Expect, T.Node>>, diff --git a/tests/types/match.test.ts b/tests/types/match.test.ts index 3caffd6..319a78b 100644 --- a/tests/types/match.test.ts +++ b/tests/types/match.test.ts @@ -1,8 +1,8 @@ -import type { Match as MatchIt, Parse as ParseIt } from '../../src/index' +import type { Query } from '../../src/index' import type { Equal, Expect } from '../../src/utils' import type { TSESTree as T } from '@typescript-eslint/typescript-estree' -type Match<_T extends string> = MatchIt, T.Node> +type Match<_T extends string> = Query<_T, T.Node> export type TestCases = [ Expect, T.Program>>, diff --git a/tests/utils/gen-tests.ts b/tests/utils/gen-tests.ts index 50eade2..2b50407 100644 --- a/tests/utils/gen-tests.ts +++ b/tests/utils/gen-tests.ts @@ -29,11 +29,11 @@ function genMatcherTestsFromPairs( const srcPath = srcPathRelativeFrom(destPath) const indexPath = JSON.stringify(path.join(srcPath, 'index')) const utilsPath = JSON.stringify(path.join(srcPath, 'utils')) - let content = `import type { Match as MatchIt, Parse as ParseIt } from ${indexPath} + let content = `import type { Query } from ${indexPath} import type { Equal, Expect } from ${utilsPath} import type { TSESTree as T } from '@typescript-eslint/typescript-estree' -type Match<_T extends string> = MatchIt, T.Node> +type Match<_T extends string> = Query<_T, T.Node> export type TestCases = [ `