Skip to content

Commit

Permalink
chore: Improve jsonCompatibleStrings deprecation (#15480)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Mar 10, 2023
1 parent 0215e04 commit 864b086
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
10 changes: 1 addition & 9 deletions packages/babel-generator/src/generators/types.ts
Expand Up @@ -209,15 +209,7 @@ export function StringLiteral(this: Printer, node: t.StringLiteral) {
return;
}

const val = jsesc(
node.value,
process.env.BABEL_8_BREAKING
? this.format.jsescOption
: Object.assign(
this.format.jsescOption,
this.format.jsonCompatibleStrings && { json: true },
),
);
const val = jsesc(node.value, this.format.jsescOption);

return this.token(val);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-generator/src/index.ts
Expand Up @@ -77,7 +77,7 @@ function normalizeOptions(

if (!process.env.BABEL_8_BREAKING) {
format.decoratorsBeforeExport = opts.decoratorsBeforeExport;
format.jsonCompatibleStrings = opts.jsonCompatibleStrings;
format.jsescOption.json = opts.jsonCompatibleStrings;
}

if (format.minified) {
Expand Down
3 changes: 3 additions & 0 deletions packages/babel-generator/src/printer.ts
Expand Up @@ -64,6 +64,9 @@ export type Format = {
};
recordAndTupleSyntaxType: RecordAndTuplePluginOptions["syntaxType"];
jsescOption: jsescOptions;
/**
* @deprecated Removed in Babel 8, use `jsescOption` instead
*/
jsonCompatibleStrings?: boolean;
/**
* For use with the Hack-style pipe operator.
Expand Down

0 comments on commit 864b086

Please sign in to comment.