Skip to content

Commit

Permalink
fix(SignatureParser): accept ConstructorSignature and `IndexSignatu…
Browse files Browse the repository at this point in the history
…re` kinds
  • Loading branch information
RealShadowNova committed May 13, 2023
1 parent bd2806e commit 2735942
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
44 changes: 35 additions & 9 deletions src/bin/lib/migrateProjectJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ export function migrateProjectJson(

case '7.4.0':

case '8.0.0': {
case '8.0.0':

case '8.0.1': {
const { variables } = projectJson as Migration.MajorSix.MinorZero.ProjectJson;

return {
Expand Down Expand Up @@ -306,7 +308,9 @@ function migrateClassJson(

case '7.4.0':

case '8.0.0': {
case '8.0.0':

case '8.0.1': {
const { typeParameters, construct } = classJson as Migration.MajorSeven.MinorTwo.ClassJson;

return {
Expand Down Expand Up @@ -454,7 +458,9 @@ function migrateEnum(

case '7.4.0':

case '8.0.0': {
case '8.0.0':

case '8.0.1': {
const { members } = enumJson as Migration.MajorSix.MinorZero.EnumJson;

return {
Expand Down Expand Up @@ -547,6 +553,8 @@ function migrateFunction(
case '7.4.0':

case '8.0.0':

case '8.0.1':
return {
id,
name,
Expand Down Expand Up @@ -684,7 +692,9 @@ function migrateInterface(

case '7.4.0':

case '8.0.0': {
case '8.0.0':

case '8.0.1': {
const { typeParameters, methods } = interfaceJson as Migration.MajorSeven.MinorOne.InterfaceJson;

return {
Expand Down Expand Up @@ -807,7 +817,9 @@ function migrateNamespace(

case '7.4.0':

case '8.0.0': {
case '8.0.0':

case '8.0.1': {
const { variables } = namespaceJson as Migration.MajorSix.MinorZero.NamespaceJson;

return {
Expand Down Expand Up @@ -891,6 +903,8 @@ function migrateTypeAlias(
case '7.4.0':

case '8.0.0':

case '8.0.1':
return {
id,
name,
Expand Down Expand Up @@ -963,6 +977,8 @@ function migrateVariable(
case '7.4.0':

case '8.0.0':

case '8.0.1':
return {
id,
name,
Expand Down Expand Up @@ -1039,7 +1055,9 @@ function migrateSourceJson(

case '7.4.0':

case '8.0.0': {
case '8.0.0':

case '8.0.1': {
const { url } = sourceJson as Migration.MajorThree.MinorZero.Misc.SourceJson;

return {
Expand Down Expand Up @@ -1147,7 +1165,9 @@ function migrateParameterJson(

case '7.4.0':

case '8.0.0': {
case '8.0.0':

case '8.0.1': {
const { comment, rest, optional } = parameterJson as Migration.MajorSeven.MinorTwo.Misc.ParameterJson;

return { id, name, comment, rest, optional, type: migrateTypeJson(type, typeDocJsonParserVersion) };
Expand Down Expand Up @@ -1226,7 +1246,9 @@ function migrateSignatureJson(

case '7.4.0':

case '8.0.0': {
case '8.0.0':

case '8.0.1': {
const { comment } = signatureJson as Migration.MajorTwo.MinorThree.Misc.SignatureJson;

return {
Expand Down Expand Up @@ -1307,7 +1329,9 @@ function migrateTypeParameterJson(

case '7.4.0':

case '8.0.0': {
case '8.0.0':

case '8.0.1': {
const { constraint } = typeParameterJson as Migration.MajorSeven.MinorZero.Misc.TypeParameterJson;

return {
Expand Down Expand Up @@ -1390,6 +1414,8 @@ export function migrateTypeJson(typeJson: Migration.MajorTwo.MinorOne.TypeJson,
}

case '8.0.0':

case '8.0.1':
return typeJson;
}

Expand Down
8 changes: 6 additions & 2 deletions src/lib/structures/misc/SignatureParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ export class SignatureParser {
public static generateFromTypeDoc(reflection: JSONOutput.SignatureReflection): SignatureParser {
const { kind, id, name, comment = { summary: [] }, typeParameter: typeParameters = [], parameters = [], type } = reflection;

if (kind !== ReflectionKind.CallSignature) {
throw new Error(`Expected Call Signature (${ReflectionKind.CallSignature}), but received ${reflectionKindToString(kind)} (${kind})`);
if (![ReflectionKind.CallSignature, ReflectionKind.ConstructorSignature, ReflectionKind.IndexSignature].includes(kind)) {
throw new Error(
`Expected Signature (${ReflectionKind.CallSignature}, ${ReflectionKind.ConstructorSignature}, ${
ReflectionKind.IndexSignature
}), but received ${reflectionKindToString(kind)} (${kind})`
);
}

return new SignatureParser({
Expand Down

0 comments on commit 2735942

Please sign in to comment.