File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1061,7 +1061,12 @@ namespace ts {
1061
1061
1062
1062
function errorByThrowType(location: Node | undefined, type: Type) {
1063
1063
if (type.flags & TypeFlags.ThrowType) type = (<ThrowType>type).value;
1064
- const message = getTypeNameForErrorDisplay(type);
1064
+ let message = "";
1065
+ if (type.flags & TypeFlags.StringLiteral) {
1066
+ message = (<StringLiteralType>type).value;
1067
+ } else {
1068
+ message = getTypeNameForErrorDisplay(type)
1069
+ };
1065
1070
error(location, Diagnostics.Type_instantiated_results_in_a_throw_type_saying_Colon_0, message);
1066
1071
}
1067
1072
@@ -22485,6 +22490,7 @@ namespace ts {
22485
22490
checkNestedBlockScopedBinding(node, symbol);
22486
22491
22487
22492
const type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node);
22493
+ if (type.flags & TypeFlags.ThrowType) errorByThrowType(node, type);
22488
22494
const assignmentKind = getAssignmentTargetKind(node);
22489
22495
22490
22496
if (assignmentKind) {
You can’t perform that action at this time.
0 commit comments