diff --git a/src/preprocessors/preprocessor.ts b/src/preprocessors/preprocessor.ts index 14d276a..6c54fe9 100644 --- a/src/preprocessors/preprocessor.ts +++ b/src/preprocessors/preprocessor.ts @@ -26,7 +26,7 @@ export function preprocessor(code: string, options: PrettierOptions): string { traverse(ast, { ImportDeclaration(path: NodePath) { const tsModuleParent = path.findParent((p) => - isTSModuleDeclaration(p), + isTSModuleDeclaration(p.node), ); if (!tsModuleParent) { allOriginalImportNodes.push(path.node); diff --git a/src/utils/get-code-from-ast.ts b/src/utils/get-code-from-ast.ts index bf27c77..bfc4f73 100644 --- a/src/utils/get-code-from-ast.ts +++ b/src/utils/get-code-from-ast.ts @@ -67,8 +67,10 @@ export const getCodeFromAst = ({ start: 0, end: 0, loc: { - start: { line: 0, column: 0 }, - end: { line: 0, column: 0 }, + start: { line: 0, column: 0, index: 0 }, + end: { line: 0, column: 0, index: 0 }, + filename: '', + identifierName: '', }, }); diff --git a/src/utils/get-comment-registry.ts b/src/utils/get-comment-registry.ts index 33b9ac0..e85671e 100644 --- a/src/utils/get-comment-registry.ts +++ b/src/utils/get-comment-registry.ts @@ -429,6 +429,8 @@ export function attachCommentsToOutputNodes( ...firstImport.loc?.end, line: firstImport.loc?.end.line + commentHeight, }, + filename: '', + identifierName: '' }; const moveDist = @@ -536,8 +538,10 @@ function ensureEmptyStatementAtFront(outputNodes: ImportOrLine[]) { } const dummy = emptyStatement(); dummy.loc = { - start: { line: 0, column: 0 }, - end: { line: 0, column: 0 }, + start: { line: 0, column: 0, index: 0 }, + end: { line: 0, column: 0, index: 0 }, + filename: '', + identifierName: '', }; outputNodes.unshift(dummy); } diff --git a/src/utils/get-import-nodes.ts b/src/utils/get-import-nodes.ts index 4bcc0f6..9825382 100644 --- a/src/utils/get-import-nodes.ts +++ b/src/utils/get-import-nodes.ts @@ -15,7 +15,7 @@ export const getImportNodes = ( traverse(ast, { ImportDeclaration(path: NodePath) { const tsModuleParent = path.findParent((p) => - isTSModuleDeclaration(p), + isTSModuleDeclaration(p.node), ); if (!tsModuleParent) { importNodes.push(path.node);