Skip to content

Commit

Permalink
deconflict #-identifiers in function names (Rich-Harris#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Nov 12, 2019
1 parent ac5a173 commit 2c25fd5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/print/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ const handlers: Record<string, Handler> = {

if (node.async) chunks.push(c('async '));
chunks.push(c(node.generator ? 'function* ' : 'function '));
if (node.id) chunks.push(c(node.id.name, node.id));
if (node.id) chunks.push(...handle(node.id, state));
chunks.push(c('('));

const params = node.params.map(p => handle(p, {
Expand Down
7 changes: 7 additions & 0 deletions test/samples/function-declaration/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function foo() {
bar
}

function foo$1() {
bar
}
11 changes: 11 additions & 0 deletions test/samples/function-declaration/expected.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/samples/function-declaration/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = ({ b }) => b`
function foo() {
bar;
}
function #foo() {
bar;
}`

0 comments on commit 2c25fd5

Please sign in to comment.