-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: regression in
getReferencingNodesInOtherSourceFiles
with sourc…
- Loading branch information
Showing
5 changed files
with
72 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { InMemoryFileSystemHost } from "@ts-morph/common"; | ||
import { expect } from "chai"; | ||
import { Project } from "../../Project"; | ||
|
||
describe("tests for issue #1227", () => { | ||
it("should find referencing source files", () => { | ||
const fileSystem = new InMemoryFileSystemHost(); | ||
fileSystem.writeFileSync( | ||
"/server.ts", | ||
`import { run } from './mid'`, | ||
); | ||
fileSystem.writeFileSync( | ||
"/mid.ts", | ||
`import {A, B} from './constants'; | ||
export function run() { | ||
console.log(A, B); | ||
return null as any; | ||
} | ||
`, | ||
); | ||
fileSystem.writeFileSync( | ||
"/constants.ts", | ||
`export const A = 'a'; | ||
export const B = 'b'; | ||
`, | ||
); | ||
fileSystem.writeFileSync( | ||
"/tsconfig.json", | ||
`{ | ||
"exclude": [ | ||
"node_modules" | ||
], | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es6", | ||
"outDir": "./dist", | ||
"baseUrl": ".", | ||
}, | ||
"files": [ | ||
"./server.ts", | ||
] | ||
}`, | ||
); | ||
const project = new Project({ fileSystem, tsConfigFilePath: "/tsconfig.json" }); | ||
|
||
const file = project.getSourceFileOrThrow("constants.ts"); | ||
expect(file.getReferencingNodesInOtherSourceFiles().map(n => n.getText())) | ||
.to.deep.equal(["import {A, B} from './constants';"]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters