fix(codegen): fixed typings codegen, added a test
This commit is contained in:
parent
ad29b2af17
commit
2a97616d80
3 changed files with 16 additions and 2 deletions
|
@ -339,7 +339,7 @@ export class BaseTelegramClient extends EventEmitter {
|
|||
langCode: 'en',
|
||||
...(opts.initConnectionOptions ?? {}),
|
||||
apiId,
|
||||
query: null,
|
||||
query: null as any,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ export function generateTypescriptDefinitionsForTlEntry(
|
|||
|
||||
genericsIndex[it.name] = 1
|
||||
if (idx !== 0) genericsString += ', '
|
||||
genericsString += `${it.name} extends ${tsType}`
|
||||
genericsString += `${it.name} extends ${tsType} = ${tsType}`
|
||||
})
|
||||
genericsString += '>'
|
||||
}
|
||||
|
|
|
@ -73,6 +73,20 @@ describe('generateReaderCodeForTlEntry', () => {
|
|||
)
|
||||
})
|
||||
|
||||
it('generates code for constructors with arguments before flags field', () => {
|
||||
test(
|
||||
'poll#86e18161 id:long flags:# quiz:flags.3?true question:string = Poll;',
|
||||
'var id=r.long(),',
|
||||
'flags=r.uint();',
|
||||
'return{',
|
||||
"_:'poll',",
|
||||
'id:id,',
|
||||
'quiz:!!(flags&8),',
|
||||
'question:r.string(),',
|
||||
'}'
|
||||
)
|
||||
})
|
||||
|
||||
it('generates code for constructors with multiple flags fields', () => {
|
||||
test(
|
||||
'updates.channelDifferenceEmpty#3e11affb flags:# final:flags.0?true pts:int timeout:flags.1?int flags2:# can_delete_channel:flags2.0?true = updates.ChannelDifference;',
|
||||
|
|
Loading…
Reference in a new issue