in compiler/src/model/utils.ts [566:618]
type: modelType(type)
}
} catch (e) {
throw new Error(`cannot determine type of ${name}, got:${type.getFullText()}`)
}
hoistPropertyAnnotations(property, declaration.getJsDocs())
return property
}
/**
* Pulls @deprecated from types and properties
*/
function setDeprecated (type: model.BaseType | model.Property | model.EnumMember, tags: Record<string, string>, jsDocs: JSDoc[]): void {
const deprecation = parseDeprecation(tags, jsDocs)
if (deprecation != null) {
type.deprecation = deprecation
}
}
export function parseDeprecation (tags: Record<string, string>, jsDocs: JSDoc[]): model.Deprecation | undefined {
if (tags.deprecated !== undefined) {
const [version, ...description] = tags.deprecated.split(' ')
assert(jsDocs, semver.valid(version), 'Invalid semver value')
delete tags.deprecated
return { version, description: description.join(' ') }
} else {
return undefined
}
}
/**
* Validates ands sets jsDocs tags used throughout the input specification
*/
function setTags<TType extends model.BaseType | model.Property | model.EnumMember> (
jsDocs: JSDoc[],
type: TType,
tags: Record<string, string>,
validTags: string[],
setter: ((tags: Record<string, string>, tag: string, value: string) => void)
): void {
if (Object.keys(tags).length === 0) return
setDeprecated(type, tags, jsDocs)
const badTags = Object.keys(tags).filter(tag => !validTags.includes(tag))
assert(
jsDocs,
badTags.length === 0,
`'${getName(type)}' has the following unknown annotations: ${badTags.join(', ')}`
)
for (const tag of validTags) {
if (tag === 'behavior' || tag === 'behavior_meta') continue
if (tags[tag] !== undefined) {