diff --git a/src/index.ts b/src/index.ts index cfd3b27..7c47787 100644 --- a/src/index.ts +++ b/src/index.ts @@ -56,7 +56,7 @@ export function extract(nodes: MfmNode[], type: (MfmNode['type'] | MfmNode['type return dest; } -export { getNodeByType } from './node'; +export { NodeType } from './node'; export { MfmNode, diff --git a/src/node.ts b/src/node.ts index c4ebb2d..bb7e2b3 100644 --- a/src/node.ts +++ b/src/node.ts @@ -158,7 +158,7 @@ export type MfmText = { children?: []; }; -export type getNodeByType = +export type NodeType = T extends 'quote' ? MfmQuote : T extends 'search' ? MfmSearch : T extends 'blockCode' ? MfmCodeBlock : diff --git a/test-d/index.ts b/test-d/index.ts index 18e8fef..8a819e6 100644 --- a/test-d/index.ts +++ b/test-d/index.ts @@ -4,11 +4,11 @@ */ import { expectType } from 'tsd'; -import { getNodeByType, MfmUrl } from '../built'; +import { NodeType, MfmUrl } from '../built'; -describe('#getNodeByType', () => { +describe('#NodeType', () => { it('returns node that has sprcified type', () => { - const x = null as unknown as getNodeByType<'url'>; + const x = null as unknown as NodeType<'url'>; expectType(x); }); });