Skip to content

Commit

Permalink
chore: Updates for #909.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jan 31, 2021
1 parent 398d946 commit 58ec871
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
7 changes: 6 additions & 1 deletion packages/bootstrap/lib/ts-morph-bootstrap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ export interface ProjectOptions {
fileSystem?: FileSystemHost;
/** Creates a resolution host for specifying custom module and/or type reference directive resolution. */
resolutionHost?: ResolutionHostFactory;
isKnownTypesPackageName?: ts.LanguageServiceHost['isKnownTypesPackageName'];
/**
* 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"];
}

/** Project that holds source files. */
Expand Down
9 changes: 7 additions & 2 deletions packages/bootstrap/src/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export interface ProjectOptions {
fileSystem?: FileSystemHost;
/** Creates a resolution host for specifying custom module and/or type reference directive resolution. */
resolutionHost?: ResolutionHostFactory;
isKnownTypesPackageName?: ts.LanguageServiceHost['isKnownTypesPackageName'];
/**
* 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"];
}

/**
Expand Down Expand Up @@ -153,7 +158,7 @@ export class Project {
getNewLine: () => newLineKind,
resolutionHost: resolutionHost || {},
getProjectVersion: () => this._sourceFileCache.getProjectVersion().toString(),
isKnownTypesPackageName: options.isKnownTypesPackageName
isKnownTypesPackageName: options.isKnownTypesPackageName,
});
this.languageServiceHost = languageServiceHost;
this.compilerHost = compilerHost;
Expand Down
8 changes: 3 additions & 5 deletions packages/common/src/compiler/createHosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ export interface CreateHostsOptions {
/** Provides the current project version to be used to tell if source files have
* changed. Provide this for a performance improvement. */
getProjectVersion?: () => string;
isKnownTypesPackageName?: ts.LanguageServiceHost['isKnownTypesPackageName'];
isKnownTypesPackageName?: ts.LanguageServiceHost["isKnownTypesPackageName"];
}

const returnTrue = () => true;

/**
* Creates a language service host and compiler host.
* @param options - Options for creating the hosts.
Expand Down Expand Up @@ -68,8 +66,8 @@ export function createHosts(options: CreateHostsOptions) {
);
}
},
isKnownTypesPackageName: isKnownTypesPackageName || returnTrue,
useCaseSensitiveFileNames: returnTrue,
isKnownTypesPackageName,
useCaseSensitiveFileNames: () => true,
readFile: (path, encoding) => {
const standardizedPath = transactionalFileSystem.getStandardizedAbsolutePath(path);
if (sourceFileContainer.containsSourceFileAtPath(standardizedPath))
Expand Down

0 comments on commit 58ec871

Please sign in to comment.