mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-11-29 12:46:32 +03:00
don't use in
, use hasOwnProperty to avoid weird collisions
This commit is contained in:
parent
9922ab2a94
commit
ee9a956c9f
@ -10,13 +10,13 @@ export const replace = (
|
|||||||
const visitor = (node: ts.Node): ts.VisitResult<ts.Node> => {
|
const visitor = (node: ts.Node): ts.VisitResult<ts.Node> => {
|
||||||
if (ts.isVariableStatement(node)) {
|
if (ts.isVariableStatement(node)) {
|
||||||
const name = node.declarationList.declarations[0]?.name;
|
const name = node.declarationList.declarations[0]?.name;
|
||||||
if (isIdentifier(name) && name.text in replacements) {
|
if (isIdentifier(name) && replacements.hasOwnProperty(name.text)) {
|
||||||
const key = name.text as keyof typeof replacements;
|
const key = name.text as keyof typeof replacements;
|
||||||
return ast(replacements[key]);
|
return ast(replacements[key]);
|
||||||
}
|
}
|
||||||
} else if (ts.isFunctionDeclaration(node)) {
|
} else if (ts.isFunctionDeclaration(node)) {
|
||||||
const name = node.name;
|
const name = node.name;
|
||||||
if (name && isIdentifier(name) && name.text in replacements) {
|
if (name && isIdentifier(name) && replacements.hasOwnProperty(name.text)) {
|
||||||
const key = name.text as keyof typeof replacements;
|
const key = name.text as keyof typeof replacements;
|
||||||
return astNodes(replacements[key]);
|
return astNodes(replacements[key]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user