File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1061,7 +1061,12 @@ namespace ts {
10611061
10621062 function errorByThrowType(location: Node | undefined, type: Type) {
10631063 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+ };
10651070 error(location, Diagnostics.Type_instantiated_results_in_a_throw_type_saying_Colon_0, message);
10661071 }
10671072
@@ -22485,6 +22490,7 @@ namespace ts {
2248522490 checkNestedBlockScopedBinding(node, symbol);
2248622491
2248722492 const type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node);
22493+ if (type.flags & TypeFlags.ThrowType) errorByThrowType(node, type);
2248822494 const assignmentKind = getAssignmentTargetKind(node);
2248922495
2249022496 if (assignmentKind) {
You can’t perform that action at this time.
0 commit comments