Skip to content

Commit

Permalink
Add return annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Oct 21, 2024
1 parent c85cf1f commit 894d492
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util/file_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type FileSource = {

export type FileSources = FileSource[];

export async function collectCustomBehaviors(sources: string[]) {
export async function collectCustomBehaviors(sources: string[]): Promise<FileSources> {
const collectedSources: FileSources = [];

for (const fileSource of sources) {
Expand All @@ -33,7 +33,7 @@ export async function collectCustomBehaviors(sources: string[]) {
return collectedSources;
}

async function collectOnlineBehavior(url: string) {
async function collectOnlineBehavior(url: string): Promise<FileSources> {
const filename = crypto.randomBytes(4).toString("hex") + ".js";
const behaviorFilepath = `/app/behaviors/${filename}`;

Expand All @@ -57,7 +57,7 @@ async function collectOnlineBehavior(url: string) {
return [];
}

async function collectLocalPathBehaviors(fileOrDir: string, depth = 0) {
async function collectLocalPathBehaviors(fileOrDir: string, depth = 0): Promise<FileSources> {
const resolvedPath = path.resolve(fileOrDir);

if (depth >= MAX_DEPTH) {
Expand All @@ -83,7 +83,7 @@ async function collectLocalPathBehaviors(fileOrDir: string, depth = 0) {

if (stat.isDirectory()) {
const files = await fsp.readdir(resolvedPath);
return files.reduce<FileSources>((acc: FileSources, next: string) => {
return files.reduce((acc: FileSources, next: string) => {
const nextPath = path.join(fileOrDir, next);
return [...acc, ...collectLocalPathBehaviors(nextPath, depth + 1)];

Check failure on line 88 in src/util/file_reader.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Type 'Promise<FileSources>' must have a '[Symbol.iterator]()' method that returns an iterator.
}, []);
Expand Down

0 comments on commit 894d492

Please sign in to comment.