Skip to content

Commit

Permalink
fix: idenfier emit error
Browse files Browse the repository at this point in the history
  • Loading branch information
cxtom committed Jun 21, 2019
1 parent d4a4ecd commit 8492792
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3248,27 +3248,21 @@ export function emitFile(
// return idText(node);
// }
if (isIdentifier(node)) {
let head = '';
let tail = '';

const text = idText(<ts.Identifier>node);

// 需要加 $
if (shouldAddDollar(node, state)) {
head = '$' + head;
return '$' + text;
}

// 需要加双引号
if (shouldAddDoubleQuote(node)) {
head = '"' + head;
tail += '"';
return '"' + text.replace(/(\\)?\$/g, '\\$') + '"';
}

// 是从模块中引入的
// if (state.moduleNamedImports[name]) {
// const className = state.moduleNamedImports[name].className;
// head = className + '::' + head;
// }
return text;

return head + idText(<ts.Identifier>node).replace(/(\\)?\$/g, '\\$') + tail;
}

if (isImportSpecifier(node)) {
Expand Down

0 comments on commit 8492792

Please sign in to comment.