diff --git a/src/index.ts b/src/index.ts index cfd3b27b24937396e683a26bae80dce3a0f21abc..7c47787c5243e68852fe18aaf5f43a7119fc509c 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 c4ebb2dda0d07e4d54e431a1b537f358710c91ad..bb7e2b3acd2afde58e087a386018e3dfb629c4db 100644 --- a/src/node.ts +++ b/src/node.ts @@ -158,7 +158,7 @@ export type MfmText = { children?: []; }; -export type getNodeByType<T extends MfmNode['type']> = +export type NodeType<T extends MfmNode['type']> = 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 18e8fef8c2252dcec4180f70c10682150ee726e6..8a819e68a95b7f74135adf2fb56edbdf9c5138d8 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<MfmUrl>(x); }); });