Update parse.ts
This commit is contained in:
		
							parent
							
								
									2eedc91d74
								
							
						
					
					
						commit
						1d3a92979f
					
				
					 1 changed files with 8 additions and 12 deletions
				
			
		|  | @ -2,18 +2,14 @@ import { mfmLanguage } from './language'; | ||||||
| import { MfmForest } from './prelude'; | import { MfmForest } from './prelude'; | ||||||
| import { normalize } from './normalize'; | import { normalize } from './normalize'; | ||||||
| 
 | 
 | ||||||
| export function parse(source: string | null): MfmForest | null { | export function parse<T extends string | null>(source: T): T extends string ? MfmForest : null { | ||||||
| 	if (source == null || source == '') { | 	return typeof source === 'string' ? | ||||||
| 		return null; | 		normalize(mfmLanguage.root.tryParse(source)) : | ||||||
| 	} | 		null as any; | ||||||
| 
 |  | ||||||
| 	return normalize(mfmLanguage.root.tryParse(source)); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function parsePlain(source: string | null): MfmForest | null { | export function parsePlain<T extends string | null>(source: T): T extends string ? MfmForest : null { | ||||||
| 	if (source == null || source == '') { | 	return typeof source === 'string' ? | ||||||
| 		return null; | 		normalize(mfmLanguage.plain.tryParse(source)) : | ||||||
| 	} | 		null as any; | ||||||
| 
 |  | ||||||
| 	return normalize(mfmLanguage.plain.tryParse(source)); |  | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue