-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
68 additions
and
197 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
135 changes: 0 additions & 135 deletions
135
stage_3_snapshot/spec-snapshot/use-cases/StringStringMap.ts
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
import fs from "fs/promises"; | ||
import path from "path"; | ||
|
||
import { | ||
type SourceFile | ||
} from "ts-morph"; | ||
|
||
import { | ||
NodeWithStructures, | ||
project, | ||
projectDir, | ||
} from "./sharedProject.js"; | ||
|
||
const TYPESCRIPT_LIBS = path.join(projectDir, "node_modules/typescript/lib"); | ||
const fileNames = (await fs.readdir(TYPESCRIPT_LIBS)).filter(f => /^lib\..*\.d.ts$/.test(f)).map(f => path.join(TYPESCRIPT_LIBS, f)); | ||
const sourceFiles: readonly SourceFile[] = project.addSourceFilesAtPaths(fileNames); | ||
|
||
export default function getTypeScriptNodes< | ||
NodeKind extends NodeWithStructures | ||
> | ||
( | ||
callback: (sourceFile: SourceFile) => NodeKind[] | ||
): [string, NodeKind][] | ||
{ | ||
return sourceFiles.map( | ||
sourceFile => processSourceFile(sourceFile, callback) | ||
).flat(); | ||
} | ||
|
||
function processSourceFile< | ||
NodeKind extends NodeWithStructures | ||
> | ||
( | ||
sourceFile: SourceFile, | ||
callback: (sourceFile: SourceFile) => NodeKind[] | ||
): [string, NodeKind][] | ||
{ | ||
const nodes = callback(sourceFile); | ||
const pathToSourceFile = sourceFile.getFilePath(); | ||
return nodes.map(node => [pathToSourceFile, node]); | ||
} |
This file was deleted.
Oops, something went wrong.