Skip to content

Commit 9f8f026

Browse files
committed
Fix usage of node parent to get source file
1 parent 2c7a18c commit 9f8f026

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/createTransformer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ export function createTransformer({
138138
*/
139139
function getDisplayNameFromNode(node: ts.Node, sourceFile: ts.SourceFile): string | undefined {
140140
if (isVariableDeclaration(node) && isIdentifier(node.name)) {
141-
return getDisplayName(node.getSourceFile().fileName, node.name.text);
141+
return getDisplayName(sourceFile.fileName, node.name.text);
142142
}
143143

144144
if (isExportAssignment(node)) {
145-
return getDisplayName(node.getSourceFile().fileName, undefined);
145+
return getDisplayName(sourceFile.fileName, undefined);
146146
}
147147

148148
return undefined;
@@ -155,7 +155,7 @@ export function createTransformer({
155155
sourceFile: ts.SourceFile
156156
): string | undefined {
157157
if ((isVariableDeclaration(node) && isIdentifier(node.name)) || isExportAssignment(node)) {
158-
const fileName = node.getSourceFile().fileName;
158+
const fileName = sourceFile.fileName;
159159
const filePath = sourceRoot
160160
? path.relative(sourceRoot, fileName).replace(path.sep, path.posix.sep)
161161
: fileName;

0 commit comments

Comments
 (0)