diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts
index 996dac118e..c266a0fa77 100644
--- a/src/compiler/emitter.ts
+++ b/src/compiler/emitter.ts
@@ -7221,7 +7221,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// Replace entities like
result = result.replace(/&(\w+);/g, function(s: any, m: string) {
if (entities[m] !== undefined) {
- return String.fromCharCode(entities[m]);
+ const ch = String.fromCharCode(entities[m]);
+ // " needs to be escaped
+ return ch === "\"" ? "\\\"" : ch;
}
else {
return s;
diff --git a/tests/baselines/reference/tsxReactEmitEntities.js b/tests/baselines/reference/tsxReactEmitEntities.js
index c1fba50fd8..a20f3380bf 100644
--- a/tests/baselines/reference/tsxReactEmitEntities.js
+++ b/tests/baselines/reference/tsxReactEmitEntities.js
@@ -8,7 +8,9 @@ declare module JSX {
declare var React: any;
Dot goes here: · ¬AnEntity;
;
+Be careful of "-ed strings!
;
//// [file.js]
React.createElement("div", null, "Dot goes here: ยท ¬AnEntity; ");
+React.createElement("div", null, "Be careful of \"-ed strings!");
diff --git a/tests/baselines/reference/tsxReactEmitEntities.symbols b/tests/baselines/reference/tsxReactEmitEntities.symbols
index b633f57ec1..5a0274029e 100644
--- a/tests/baselines/reference/tsxReactEmitEntities.symbols
+++ b/tests/baselines/reference/tsxReactEmitEntities.symbols
@@ -19,3 +19,7 @@ declare var React: any;
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
+Be careful of "-ed strings!
;
+>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
+>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
+
diff --git a/tests/baselines/reference/tsxReactEmitEntities.types b/tests/baselines/reference/tsxReactEmitEntities.types
index d6d6c285d7..111653ea14 100644
--- a/tests/baselines/reference/tsxReactEmitEntities.types
+++ b/tests/baselines/reference/tsxReactEmitEntities.types
@@ -20,3 +20,8 @@ declare var React: any;
>div : any
>div : any
+Be careful of "-ed strings!
;
+>Be careful of "-ed strings!
: JSX.Element
+>div : any
+>div : any
+
diff --git a/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx b/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx
index 4b7dc5780f..4726008d6b 100644
--- a/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx
+++ b/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx
@@ -9,3 +9,4 @@ declare module JSX {
declare var React: any;
Dot goes here: · ¬AnEntity;
;
+Be careful of "-ed strings!
;