Skip to content

Commit

Permalink
fix: Negative literal types were converted incorrectly
Browse files Browse the repository at this point in the history
Resolves #1427
  • Loading branch information
Gerrit0 committed Dec 29, 2020
1 parent 38d8edf commit c14b5b5
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 80 deletions.
6 changes: 3 additions & 3 deletions src/lib/converter/types.ts
Expand Up @@ -730,7 +730,7 @@ const literalTypeConverter: TypeConverter<

return requestBugReport(context, node.literal);
},
convertType(context, type, node) {
convertType(_context, type, node) {
switch (node.literal.kind) {
case ts.SyntaxKind.StringLiteral:
return new LiteralType(node.literal.text);
Expand All @@ -753,7 +753,7 @@ const literalTypeConverter: TypeConverter<
);
}

return requestBugReport(context, type);
return new LiteralType(type.value);
},
};

Expand Down Expand Up @@ -897,7 +897,7 @@ function requestBugReport(context: Context, nodeOrType: ts.Node | ts.Type) {
} else {
const typeString = context.checker.typeToString(nodeOrType);
context.logger.warn(
`Failed to convert type: ${typeString}. Please report a bug.`
`Failed to convert type: ${typeString} when converting ${context.scope.getFullName()}. Please report a bug.`
);
return new UnknownType(typeString);
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/converter/types/general.ts
Expand Up @@ -10,3 +10,6 @@ export type NumArray = number[];
export const numArray = makeValue<number[]>();

export type BigIntAlias = bigint;

export type NegativeOne = -1;
export const negativeOne = -1;

0 comments on commit c14b5b5

Please sign in to comment.