refactor: rename getNodeByType --> NodeType

This commit is contained in:
syuilo 2021-03-30 10:02:22 +09:00 committed by marihachi
parent 2b86b9b9b7
commit 33432fa857
3 changed files with 5 additions and 5 deletions

View file

@ -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,

View file

@ -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 :

View file

@ -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);
});
});