Skip to content

Commit 922d0e3

Browse files
fix: protocol mapping comments (#332)
1 parent 0ed0c08 commit 922d0e3

File tree

2 files changed

+361
-4
lines changed

2 files changed

+361
-4
lines changed

scripts/protocol-dts-generator.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ const emitDescription = (lines: string[]) => {
131131

132132
const emitTsComment = (object: P.Event|P.PropertyType|P.DomainType|P.Command|P.Domain) => {
133133
const commentLines = object.description ? getCommentLines(object.description) : [];
134-
if('deprecated' in object){
134+
if('deprecated' in object && object.deprecated){
135135
commentLines.push('@deprecated');
136136
}
137137

138-
if('experimental' in object){
138+
if('experimental' in object && object.experimental){
139139
commentLines.push('@experimental');
140140
}
141141

@@ -275,7 +275,7 @@ const emitEvent = (event: P.Event) => {
275275
emitInterface(toEventPayloadName(event.name), event.parameters)
276276
}
277277

278-
const getEventMapping = (event: P.Event, domainName: string, modulePrefix: string): P.RefType & P.PropertyBaseType => {
278+
const getEventMapping = (event: P.Event, domainName: string, modulePrefix: string): P.RefType & P.PropertyBaseType & P.ExtraInformation => {
279279
// Use TS3.0+ tuples
280280
const payloadType = event.parameters ?
281281
`[${modulePrefix}.${domainName}.${toEventPayloadName(event.name)}]` :
@@ -285,6 +285,8 @@ const getEventMapping = (event: P.Event, domainName: string, modulePrefix: strin
285285
// domain-prefixed name since it will be used outside of the module.
286286
name: `${domainName}.${event.name}`,
287287
description: event.description,
288+
deprecated: event.deprecated,
289+
experimental: event.experimental,
288290
$ref: payloadType
289291
}
290292
}
@@ -293,7 +295,7 @@ const isWeakInterface = (params: P.PropertyType[]): boolean => {
293295
return params.every(p => !!p.optional)
294296
}
295297

296-
const getCommandMapping = (command: P.Command, domainName: string, modulePrefix: string): P.ObjectType & P.PropertyBaseType => {
298+
const getCommandMapping = (command: P.Command, domainName: string, modulePrefix: string): P.ObjectType & P.PropertyBaseType & P.ExtraInformation => {
297299
const prefix = `${modulePrefix}.${domainName}.`
298300
// Use TS3.0+ tuples for paramsType
299301
let requestType = '[]'
@@ -307,6 +309,8 @@ const getCommandMapping = (command: P.Command, domainName: string, modulePrefix:
307309
type: 'object',
308310
name: `${domainName}.${command.name}`,
309311
description: command.description,
312+
deprecated: command.deprecated,
313+
experimental: command.experimental,
310314
properties: [{
311315
name: 'paramsType',
312316
$ref: requestType,

0 commit comments

Comments
 (0)