Skip to content

Commit

Permalink
refactor ~ alter OSPaths type for better VSCode intellisense (describ…
Browse files Browse the repository at this point in the history
…e as methods, not properties)
  • Loading branch information
rivy committed Jan 17, 2021
1 parent 67ddd71 commit ab673fa
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/lib/OSPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { Platform } from '../platform-adapters/_base';
export type OSPaths = {
new (): OSPaths;
(): OSPaths;
readonly home: () => string | undefined;
readonly temp: () => string;
/* eslint-disable functional/no-method-signature */
home(): string | undefined;
temp(): string;
/* eslint-enable functional/no-method-signature */
};

function isEmpty(s: string | null | undefined): boolean {
Expand Down Expand Up @@ -90,19 +92,14 @@ namespace Adapt {
}

export function OSPathsAdaptionBuilder_(adapter_: Platform.Adapter): OSPaths {
// eslint-disable-next-line functional/no-class
class OSPaths_ {
constructor() {
const OSPaths = function () {
return new OSPaths_() as OSPaths;
};

OSPaths.home = Adapt.home(adapter_);
OSPaths.temp = Adapt.temp(adapter_);

return OSPaths;
}
function OSPaths(): OSPaths {
return obj as OSPaths;
}

return new OSPaths_() as OSPaths;
const home = Adapt.home(adapter_);
const temp = Adapt.temp(adapter_);
const obj = Object.assign(OSPaths, {
home,
temp,
}) as OSPaths;
return obj as OSPaths;
}

0 comments on commit ab673fa

Please sign in to comment.