@ts-morph/bootstrap
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -85,2 +85,5 @@ 'use strict'; | ||
} | ||
addLibFileToCacheByText(filePath, fileText, scriptKind) { | ||
return this.documentRegistry.createOrUpdateSourceFile(filePath, this.compilerOptions.get(), common.ts.ScriptSnapshot.fromString(fileText), scriptKind); | ||
} | ||
addOrGetSourceFileFromFilePath(filePath, options) { | ||
@@ -168,5 +171,2 @@ return __awaiter(this, void 0, void 0, function* () { | ||
throw new common.errors.InvalidOperationError("Cannot provide a file system when specifying to use an in-memory file system."); | ||
if (options.skipLoadingLibFiles && !options.useInMemoryFileSystem) { | ||
throw new common.errors.InvalidOperationError(`The ${"skipLoadingLibFiles"} option can only be true when ${"useInMemoryFileSystem"} is true.`); | ||
} | ||
} | ||
@@ -176,3 +176,3 @@ function getFileSystem() { | ||
if (options.useInMemoryFileSystem) | ||
return new common.InMemoryFileSystemHost({ skipLoadingLibFiles: options.skipLoadingLibFiles }); | ||
return new common.InMemoryFileSystemHost(); | ||
return (_a = options.fileSystem) !== null && _a !== void 0 ? _a : new common.RealFileSystemHost(); | ||
@@ -208,2 +208,5 @@ } | ||
getProjectVersion: () => this._sourceFileCache.getProjectVersion().toString(), | ||
isKnownTypesPackageName: options.isKnownTypesPackageName, | ||
libFolderPath: options.libFolderPath, | ||
skipLoadingLibFiles: options.skipLoadingLibFiles, | ||
}); | ||
@@ -210,0 +213,0 @@ this.languageServiceHost = languageServiceHost; |
@@ -74,50 +74,2 @@ import { ts } from "@ts-morph/common"; | ||
/** | ||
* Factory used to create a resolution host. | ||
* @remarks The compiler options are retrieved via a function in order to get the project's current compiler options. | ||
*/ | ||
export declare type ResolutionHostFactory = (moduleResolutionHost: ts.ModuleResolutionHost, getCompilerOptions: () => ts.CompilerOptions) => ResolutionHost; | ||
/** Host for implementing custom module and/or type reference directive resolution. */ | ||
export interface ResolutionHost { | ||
resolveModuleNames?: ts.LanguageServiceHost["resolveModuleNames"]; | ||
getResolvedModuleWithFailedLookupLocationsFromCache?: ts.LanguageServiceHost["getResolvedModuleWithFailedLookupLocationsFromCache"]; | ||
resolveTypeReferenceDirectives?: ts.LanguageServiceHost["resolveTypeReferenceDirectives"]; | ||
} | ||
export declare abstract class SettingsContainer<T extends object> { | ||
protected _settings: T; | ||
/** | ||
* Constructor. | ||
* @param defaultSettings - The settings to use by default. | ||
*/ | ||
constructor(defaultSettings: T); | ||
/** | ||
* Resets the settings to the default. | ||
*/ | ||
reset(): void; | ||
/** | ||
* Gets a copy of the settings as an object. | ||
*/ | ||
get(): T; | ||
/** | ||
* Sets one or all of the settings. | ||
* @param settings - Settings to set. | ||
*/ | ||
set(settings: Partial<T>): void; | ||
/** | ||
* Subscribe to modifications in the settings container. | ||
* @param action - Action to execute when the settings change. | ||
*/ | ||
onModified(action: () => void): void; | ||
} | ||
export interface InMemoryFileSystemHostOptions { | ||
/** | ||
* Set this to true to not load the /node_modules/typescript/lib files on construction. | ||
* @default false | ||
*/ | ||
skipLoadingLibFiles?: boolean; | ||
} | ||
/** An implementation of a file system that exists in memory only. */ | ||
@@ -127,5 +79,4 @@ export declare class InMemoryFileSystemHost implements FileSystemHost { | ||
* Constructor. | ||
* @param options - Options for creating the file system. | ||
*/ | ||
constructor(options?: InMemoryFileSystemHostOptions); | ||
constructor(); | ||
/** @inheritdoc */ | ||
@@ -177,3 +128,43 @@ isCaseSensitive(): boolean; | ||
/** Host for implementing custom module and/or type reference directive resolution. */ | ||
export interface ResolutionHost { | ||
resolveModuleNames?: ts.LanguageServiceHost["resolveModuleNames"]; | ||
getResolvedModuleWithFailedLookupLocationsFromCache?: ts.LanguageServiceHost["getResolvedModuleWithFailedLookupLocationsFromCache"]; | ||
resolveTypeReferenceDirectives?: ts.LanguageServiceHost["resolveTypeReferenceDirectives"]; | ||
} | ||
/** | ||
* Factory used to create a resolution host. | ||
* @remarks The compiler options are retrieved via a function in order to get the project's current compiler options. | ||
*/ | ||
export declare type ResolutionHostFactory = (moduleResolutionHost: ts.ModuleResolutionHost, getCompilerOptions: () => ts.CompilerOptions) => ResolutionHost; | ||
export declare abstract class SettingsContainer<T extends object> { | ||
protected _settings: T; | ||
/** | ||
* Constructor. | ||
* @param defaultSettings - The settings to use by default. | ||
*/ | ||
constructor(defaultSettings: T); | ||
/** | ||
* Resets the settings to the default. | ||
*/ | ||
reset(): void; | ||
/** | ||
* Gets a copy of the settings as an object. | ||
*/ | ||
get(): T; | ||
/** | ||
* Sets one or all of the settings. | ||
* @param settings - Settings to set. | ||
*/ | ||
set(settings: Partial<T>): void; | ||
/** | ||
* Subscribe to modifications in the settings container. | ||
* @param action - Action to execute when the settings change. | ||
*/ | ||
onModified(action: () => void): void; | ||
} | ||
/** | ||
* Asynchronously creates a new collection of source files to analyze. | ||
@@ -200,4 +191,12 @@ * @param options Options for creating the project. | ||
skipFileDependencyResolution?: boolean; | ||
/** Skip loading the lib files when using an in-memory file system. @default false */ | ||
/** | ||
* Skip loading the lib files. Unlike the compiler API, ts-morph does not load these | ||
* from the node_modules folder, but instead loads them from some other JS code | ||
* and uses a fake path for their existence. If you want to use a custom lib files | ||
* folder path, then provide one using the libFolderPath options. | ||
* @default false | ||
*/ | ||
skipLoadingLibFiles?: boolean; | ||
/** The folder to use for loading lib files. */ | ||
libFolderPath?: string; | ||
/** Whether to use an in-memory file system. */ | ||
@@ -212,2 +211,8 @@ useInMemoryFileSystem?: boolean; | ||
resolutionHost?: ResolutionHostFactory; | ||
/** | ||
* Unstable and will probably be removed in the future. | ||
* I believe this option should be internal to the library and if you know how to achieve | ||
* that then please consider submitting a PR. | ||
*/ | ||
isKnownTypesPackageName?: ts.LanguageServiceHost["isKnownTypesPackageName"]; | ||
} | ||
@@ -214,0 +219,0 @@ |
{ | ||
"name": "@ts-morph/bootstrap", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "API for getting quickly set up with the TypeScript Compiler API.", | ||
@@ -21,20 +21,20 @@ "keywords": ["typescript", "compiler", "bootstrap"], | ||
"dependencies": { | ||
"@ts-morph/common": "~0.7.0" | ||
"@ts-morph/common": "~0.8.0" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.2.14", | ||
"@types/mocha": "^8.0.4", | ||
"@types/mocha": "^8.2.0", | ||
"@types/ts-nameof": "^4.2.1", | ||
"@ts-morph/scripts": "~0.2.0", | ||
"chai": "^4.2.0", | ||
"cross-env": "^7.0.2", | ||
"chai": "^4.3.0", | ||
"cross-env": "^7.0.3", | ||
"mocha": "^8.2.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.33.3", | ||
"rollup": "^2.38.5", | ||
"rollup-plugin-typescript2": "^0.29.0", | ||
"ts-morph": "npm:ts-morph@8.2.0", | ||
"ts-morph": "npm:ts-morph@9.0.0", | ||
"ts-nameof": "^5.0.0", | ||
"ts-node": "^9.0.0", | ||
"ts-node": "^9.1.1", | ||
"ttypescript": "^1.5.12", | ||
"typescript": "~4.1.2" | ||
"typescript": "~4.1.3" | ||
}, | ||
@@ -41,0 +41,0 @@ "publishConfig": { |
# @ts-morph/bootstrap | ||
[![npm version](https://badge.fury.io/js/%40ts-morph%2Fbootstrap.svg)](https://badge.fury.io/js/%40ts-morph%2Fbootstrap) | ||
[![Build Status](https://travis-ci.org/dsherret/ts-morph.svg?branch=latest)](https://travis-ci.org/dsherret/ts-morph) | ||
[![CI](https://github.com/dsherret/ts-morph/workflows/CI/badge.svg)](https://github.com/dsherret/ts-morph/actions?query=workflow%3ACI) | ||
@@ -6,0 +6,0 @@ A library for quickly getting set up with the [TypeScript](https://github.com/Microsoft/TypeScript) Compiler API. |
47104
809
+ Added@ts-morph/common@0.8.1(transitive)
- Removed@ts-morph/common@0.7.5(transitive)
- Removedtypescript@4.1.6(transitive)
Updated@ts-morph/common@~0.8.0