@ts-morph/bootstrap
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -151,3 +151,3 @@ 'use strict'; | ||
} | ||
addSourceFiles(fileGlobs) { | ||
addSourceFilesByPaths(fileGlobs) { | ||
if (typeof fileGlobs === "string") | ||
@@ -154,0 +154,0 @@ fileGlobs = [fileGlobs]; |
@@ -173,3 +173,3 @@ import { ts } from "@ts-morph/common"; | ||
*/ | ||
addSourceFiles(fileGlobs: string | ReadonlyArray<string>): ts.SourceFile[]; | ||
addSourceFilesByPaths(fileGlobs: string | ReadonlyArray<string>): ts.SourceFile[]; | ||
/** | ||
@@ -176,0 +176,0 @@ * Adds all the source files from the specified tsconfig.json. |
{ | ||
"name": "@ts-morph/bootstrap", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "API for getting quickly set up with the TypeScript Compiler API.", | ||
@@ -5,0 +5,0 @@ "keywords": ["typescript", "compiler", "bootstrap"], |
@@ -20,9 +20,19 @@ # @ts-morph/bootstrap | ||
// these are typed as ts.SourceFile | ||
const myClassFile = project.createSourceFile("MyClass.ts", "export class MyClass { prop: string; }"); | ||
const mainFile = project.createSourceFile("main.ts", "import { MyClass } from './MyClass.ts'"); | ||
const myClassFile = project.createSourceFile( | ||
"MyClass.ts", | ||
"export class MyClass { prop: string; }" | ||
); | ||
const mainFile = project.createSourceFile( | ||
"main.ts", | ||
"import { MyClass } from './MyClass.ts'" | ||
); | ||
const program = project.createProgram(); // ts.Program | ||
const typeChecker = program.getTypeChecker(); // ts.TypeChecker | ||
const languageService = project.getLanguageService(); // ts.LanguageService | ||
const moduleResolutionHost = project.getModuleResolutionHost(); // ts.ModuleResolutionHost | ||
// ts.Program | ||
const program = project.createProgram(); | ||
// ts.TypeChecker | ||
const typeChecker = program.getTypeChecker(); | ||
// ts.LanguageService | ||
const languageService = project.getLanguageService(); | ||
// ts.ModuleResolutionHost | ||
const moduleResolutionHost = project.getModuleResolutionHost(); | ||
``` | ||
@@ -101,3 +111,4 @@ | ||
// this is deno style module resolution (ex. `import { MyClass } from "./MyClass.ts"`) | ||
// This is deno style module resolution. | ||
// Ex. `import { MyClass } from "./MyClass.ts"`; | ||
const project = new Project({ | ||
@@ -111,3 +122,9 @@ resolutionHost: (moduleResolutionHost, getCompilerOptions) => { | ||
for (const moduleName of moduleNames.map(removeTsExtension)) { | ||
const result = ts.resolveModuleName(moduleName, containingFile, compilerOptions, moduleResolutionHost); | ||
const result = ts.resolveModuleName( | ||
moduleName, | ||
containingFile, | ||
compilerOptions, | ||
moduleResolutionHost | ||
); | ||
if (result.resolvedModule) | ||
@@ -134,3 +151,3 @@ resolvedModules.push(result.resolvedModule); | ||
* `const sourceFiles = project.addSourceFiles("**/*.ts");` or provide an array of file globs. | ||
* `const sourceFiles = project.addSourceFilesByPaths("**/*.ts");` or provide an array of file globs. | ||
* `const sourceFile = project.addSourceFileAtPath("src/my-file.ts");` or use `addSourceFileAtPathIfExists(filePath)` | ||
@@ -137,0 +154,0 @@ * `const sourceFiles = project.addSourceFilesFromTsConfig("path/to/tsconfig.json")` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34945
192