diff --git a/src/path-alias/path-alias.test.ts b/src/path-alias/path-alias.test.ts index 1ac12f5..b3b2f5c 100644 --- a/src/path-alias/path-alias.test.ts +++ b/src/path-alias/path-alias.test.ts @@ -59,3 +59,6 @@ Deno.test("preserves .js extensions in path aliases", async () => { Deno.test("preserves .ts extensions in path aliases", async () => { await testFn("ts-extensions"); }); + +// TODO handle edge case for path alias to index.ts +// TODO handle priority collision with `@/*` => `src/*` diff --git a/src/path-alias/spec/src/services/user.ts b/src/path-alias/spec/src/services/user.ts index 0f15f85..2343970 100644 --- a/src/path-alias/spec/src/services/user.ts +++ b/src/path-alias/spec/src/services/user.ts @@ -12,6 +12,6 @@ export class UserService { } getConfig() { - return { apiUrl: "http://localhost:3000" }; + return { apiUrl: "http://localhost:3000", port: 3000 }; } } diff --git a/src/path-alias/spec/src/tests/comprehensive.in.ts b/src/path-alias/spec/src/tests/comprehensive.in.ts index 3f15db3..a10d917 100644 --- a/src/path-alias/spec/src/tests/comprehensive.in.ts +++ b/src/path-alias/spec/src/tests/comprehensive.in.ts @@ -9,15 +9,12 @@ import { Logger } from "@utils/logger"; import { Database } from "@database/connection"; // External packages (should be preserved) -import express from "express"; -import { z } from "zod"; +import { walk } from "@std/fs"; // Relative imports (should be preserved) -import { Helper } from "./helper"; -import { Constants } from "../constants"; +import { Utils } from "../utils/helpers"; // Wildcard imports -import { UserModel } from "@models/*"; import { ValidationError } from "@types/errors"; // Re-exports @@ -33,7 +30,7 @@ export class App { private authService: AuthService, private logger: Logger, private db: Database, - private helper: Helper, + private utils: Utils, ) {} async initialize() { @@ -42,12 +39,7 @@ export class App { } async createUser(userData: UserType) { - const validationSchema = z.object({ - name: z.string(), - email: z.string().email(), - }); - - const validatedData = validationSchema.parse(userData); - return this.userService.create(validatedData); + walk("test"); + return this.userService.create(userData); } } diff --git a/src/path-alias/spec/src/tests/comprehensive.out.ts b/src/path-alias/spec/src/tests/comprehensive.out.ts index e67204f..95f7c79 100644 --- a/src/path-alias/spec/src/tests/comprehensive.out.ts +++ b/src/path-alias/spec/src/tests/comprehensive.out.ts @@ -9,15 +9,12 @@ import { Logger } from "../utils/logger"; import { Database } from "../database/connection"; // External packages (should be preserved) -import express from "express"; -import { z } from "zod"; +import { walk } from "@std/fs"; // Relative imports (should be preserved) -import { Helper } from "./helper"; -import { Constants } from "../constants"; +import { Utils } from "../utils/helpers"; // Wildcard imports -import { UserModel } from "../models/index"; import { ValidationError } from "../types/errors"; // Re-exports @@ -33,7 +30,7 @@ export class App { private authService: AuthService, private logger: Logger, private db: Database, - private helper: Helper, + private utils: Utils, ) {} async initialize() { @@ -42,12 +39,7 @@ export class App { } async createUser(userData: UserType) { - const validationSchema = z.object({ - name: z.string(), - email: z.string().email(), - }); - - const validatedData = validationSchema.parse(userData); - return this.userService.create(validatedData); + walk("test"); + return this.userService.create(userData); } } diff --git a/src/path-alias/spec/src/tests/default-named-imports.out.ts b/src/path-alias/spec/src/tests/default-named-imports.out.ts index 88b8e27..6f8e169 100644 --- a/src/path-alias/spec/src/tests/default-named-imports.out.ts +++ b/src/path-alias/spec/src/tests/default-named-imports.out.ts @@ -12,7 +12,7 @@ export class App { ) {} async start() { - this.logger.info("Starting application"); - return this.userService.findAll(); + this.logger.log("Starting app", LogLevel.INFO); + await this.authService.initialize(); } } diff --git a/src/path-alias/spec/src/tests/dynamic-imports.out.ts b/src/path-alias/spec/src/tests/dynamic-imports.out.ts index 021b7f5..0445d8f 100644 --- a/src/path-alias/spec/src/tests/dynamic-imports.out.ts +++ b/src/path-alias/spec/src/tests/dynamic-imports.out.ts @@ -1,16 +1,20 @@ import { UserService } from "../services/user"; -export class DynamicImporter { - async loadModules() { - // Dynamic import with path alias +export class UserController { + constructor(private userService: UserService) {} + + async loadUserModule() { const UserModule = await import("../modules/user"); + return new UserModule.default(); + } - // Dynamic import with destructuring + async loadAuthModule() { const { AuthService } = await import("../services/auth"); + return new AuthService(); + } - // Dynamic import for config + async loadConfig() { const config = await import("../config/app"); - - return { UserModule, AuthService, config }; + return config.default; } } diff --git a/src/path-alias/spec/src/tests/re-exports.in.ts b/src/path-alias/spec/src/tests/re-exports.in.ts index 505db28..036b390 100644 --- a/src/path-alias/spec/src/tests/re-exports.in.ts +++ b/src/path-alias/spec/src/tests/re-exports.in.ts @@ -7,6 +7,6 @@ export { Logger } from "@utils/logger"; export { UserService as UserAPI } from "@services/user"; export { AuthService as AuthAPI } from "@services/auth"; -// Re-export all +// Wildcard re-exports export * from "@services/user"; export * from "@utils/logger"; diff --git a/src/path-alias/spec/src/tests/re-exports.out.ts b/src/path-alias/spec/src/tests/re-exports.out.ts index 95448cb..b292599 100644 --- a/src/path-alias/spec/src/tests/re-exports.out.ts +++ b/src/path-alias/spec/src/tests/re-exports.out.ts @@ -1,9 +1,9 @@ -// Simple re-exports +// Re-export from path aliases export { UserService } from "../services/user"; export { AuthService } from "../services/auth"; export { Logger } from "../utils/logger"; -// Re-exports with aliases +// Re-export with renaming export { UserService as UserAPI } from "../services/user"; export { AuthService as AuthAPI } from "../services/auth"; diff --git a/src/path-alias/spec/src/tests/type-imports.out.ts b/src/path-alias/spec/src/tests/type-imports.out.ts index 1da2ec6..ab517bf 100644 --- a/src/path-alias/spec/src/tests/type-imports.out.ts +++ b/src/path-alias/spec/src/tests/type-imports.out.ts @@ -4,14 +4,14 @@ import type { DatabaseType } from "../database/types"; import { UserService } from "../services/user"; -export class App { - constructor( - private userService: UserService, - private config: ConfigType, - private db: DatabaseType, - ) {} +export class UserController { + constructor(private userService: UserService) {} - async createUser(userData: UserType) { + async createUser(userData: UserType): Promise { return this.userService.create(userData); } + + getConfig(): ConfigType { + return this.userService.getConfig(); + } }