From 33432fa85714f3302c8206e8820e6ae61aa4bf28 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 30 Mar 2021 10:02:22 +0900 Subject: [PATCH] refactor: rename getNodeByType --> NodeType --- src/index.ts | 2 +- src/node.ts | 2 +- test-d/index.ts | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) 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); }); });