fix type assertion
This commit is contained in:
		
							parent
							
								
									16cdcf24ad
								
							
						
					
					
						commit
						a7d3a34103
					
				|  | @ -49,7 +49,12 @@ describe('Timeline', () => { | |||
| 			async () => { | ||||
| 				note = (await alice.client.request('notes/create', { text, ...noteParams })).createdNote; | ||||
| 			}, | ||||
| 			'note', msg => (msg as Misskey.entities.Note).text === text, | ||||
| 			'note', (msg) => { | ||||
| 				if (Misskey.note.isStreamNote(msg)) { | ||||
| 					return false; | ||||
| 				} | ||||
| 				return msg.text === text; | ||||
| 			}, | ||||
| 			channelParams, | ||||
| 		); | ||||
| 		strictEqual(streamingFired, expect); | ||||
|  |  | |||
|  | @ -80,7 +80,7 @@ async function prepend(data: Misskey.entities.Note | Misskey.entities.StreamNote | |||
| 
 | ||||
| 	let note: Misskey.entities.Note & MisskeyEntity; | ||||
| 
 | ||||
| 	if ('_allowCached_' in data) { | ||||
| 	if (Misskey.note.isStreamNote(data)) { | ||||
| 		let fullNote: Misskey.entities.Note | null = null; | ||||
| 
 | ||||
| 		const { _allowCached_, ..._data } = data; | ||||
|  | @ -91,7 +91,7 @@ async function prepend(data: Misskey.entities.Note | Misskey.entities.StreamNote | |||
| 				credentials: 'omit', | ||||
| 			}); | ||||
| 			if (!res.ok) return; | ||||
| 			fullNote = await res.json(); | ||||
| 			fullNote = (await res.json()) as Misskey.entities.Note; | ||||
| 		} else { | ||||
| 			fullNote = await misskeyApi('notes/show', { | ||||
| 				noteId: data.id, | ||||
|  |  | |||
|  | @ -2359,6 +2359,9 @@ type ISigninHistoryResponse = operations['i___signin-history']['responses']['200 | |||
| // @public (undocumented) | ||||
| function isPureRenote(note: Note): note is PureRenote; | ||||
| 
 | ||||
| // @public (undocumented) | ||||
| function isStreamNote(note: Note | StreamNote): note is StreamNote; | ||||
| 
 | ||||
| // @public (undocumented) | ||||
| export interface IStream extends EventEmitter<StreamEvents> { | ||||
|     // (undocumented) | ||||
|  | @ -2652,7 +2655,8 @@ type Note = components['schemas']['Note']; | |||
| 
 | ||||
| declare namespace note { | ||||
|     export { | ||||
|         isPureRenote | ||||
|         isPureRenote, | ||||
|         isStreamNote | ||||
|     } | ||||
| } | ||||
| export { note } | ||||
|  | @ -3194,14 +3198,13 @@ export type StreamEvents = { | |||
| } & BroadcastEvents; | ||||
| 
 | ||||
| // @public (undocumented) | ||||
| type StreamNote = ({ | ||||
| type StreamNote = { | ||||
|     id: Note['id']; | ||||
|     poll?: Pick<NonNullable<Note['poll']>, 'choices'>; | ||||
|     reply?: Pick<NonNullable<Note['reply']>, 'myReaction'>; | ||||
|     renote?: Pick<NonNullable<Note['renote']>, 'myReaction'>; | ||||
| } & { | ||||
|     _allowCached_: true; | ||||
| }) | { | ||||
| } | { | ||||
|     id: Note['id']; | ||||
|     _allowCached_: false; | ||||
| }; | ||||
|  |  | |||
|  | @ -248,14 +248,13 @@ export type AnnouncementCreated = { | |||
| 	announcement: Announcement; | ||||
| }; | ||||
| 
 | ||||
| export type StreamNote = ({ | ||||
| export type StreamNote = { | ||||
| 	id: Note['id']; | ||||
| 	poll?: Pick<NonNullable<Note['poll']>, 'choices'>; | ||||
| 	reply?: Pick<NonNullable<Note['reply']>, 'myReaction'>; | ||||
| 	renote?: Pick<NonNullable<Note['renote']>, 'myReaction'>; | ||||
| } & { | ||||
| 	_allowCached_: true; | ||||
| }) | { | ||||
| } | { | ||||
| 	id: Note['id']; | ||||
| 	_allowCached_: false; | ||||
| }; | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import type { Note, PureRenote } from './entities.js'; | ||||
| import type { Note, StreamNote, PureRenote } from './entities.js'; | ||||
| 
 | ||||
| export function isPureRenote(note: Note): note is PureRenote { | ||||
| 	return ( | ||||
|  | @ -10,3 +10,7 @@ export function isPureRenote(note: Note): note is PureRenote { | |||
| 		note.poll == null | ||||
| 	); | ||||
| } | ||||
| 
 | ||||
| export function isStreamNote(note: Note | StreamNote): note is StreamNote { | ||||
| 	return '_allowCached_' in note && typeof note._allowCached_ === 'boolean'; | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue