Skip to content

Commit c14b5b5

Browse files
committed
fix: Negative literal types were converted incorrectly
Resolves #1427
1 parent 38d8edf commit c14b5b5

File tree

3 files changed

+110
-80
lines changed

3 files changed

+110
-80
lines changed

src/lib/converter/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ const literalTypeConverter: TypeConverter<
730730

731731
return requestBugReport(context, node.literal);
732732
},
733-
convertType(context, type, node) {
733+
convertType(_context, type, node) {
734734
switch (node.literal.kind) {
735735
case ts.SyntaxKind.StringLiteral:
736736
return new LiteralType(node.literal.text);
@@ -753,7 +753,7 @@ const literalTypeConverter: TypeConverter<
753753
);
754754
}
755755

756-
return requestBugReport(context, type);
756+
return new LiteralType(type.value);
757757
},
758758
};
759759

@@ -897,7 +897,7 @@ function requestBugReport(context: Context, nodeOrType: ts.Node | ts.Type) {
897897
} else {
898898
const typeString = context.checker.typeToString(nodeOrType);
899899
context.logger.warn(
900-
`Failed to convert type: ${typeString}. Please report a bug.`
900+
`Failed to convert type: ${typeString} when converting ${context.scope.getFullName()}. Please report a bug.`
901901
);
902902
return new UnknownType(typeString);
903903
}

src/test/converter/types/general.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ export type NumArray = number[];
1010
export const numArray = makeValue<number[]>();
1111

1212
export type BigIntAlias = bigint;
13+
14+
export type NegativeOne = -1;
15+
export const negativeOne = -1;

0 commit comments

Comments
 (0)