mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-11-25 22:50:42 +03:00
Fix compile errors in replacement code.
This commit is contained in:
parent
f3a03a651e
commit
266885899e
@ -15,7 +15,7 @@ export const replace = (
|
||||
}
|
||||
} else if (ts.isFunctionDeclaration(node)) {
|
||||
const name = node.name;
|
||||
if (isIdentifier(name) && name.text in replacements) {
|
||||
if (name && isIdentifier(name) && name.text in replacements) {
|
||||
const key = name.text as keyof typeof replacements;
|
||||
return astNodes(replacements[key]);
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ export const ast = (sourceText: string): ts.Node => {
|
||||
return source.statements[0];
|
||||
};
|
||||
|
||||
export const astNodes = (sourceText: string): [ts.Node] => {
|
||||
export const astNodes = (sourceText: string): ts.Node[] => {
|
||||
const source = ts.createSourceFile('bla', sourceText, ts.ScriptTarget.ES2018);
|
||||
return source.statements;
|
||||
return Array.from(source.statements);
|
||||
}
|
||||
|
||||
export function create(name: string, body: ts.Node): ts.Node {
|
||||
|
Loading…
Reference in New Issue
Block a user