Steps to reproduce
This issue occurs in the better-auth Next.js demo, specifically in the organization plugin callback.
Original Repository: https://github.com/better-auth/better-auth/tree/main/demo/nextjs
Repro (extracted demo folder with tsgo config, without any other changes): https://github.com/Azzerty23/tsgo-issue-repro
File: lib/auth.ts, line 135
Minimal reproduction:
import { organization } from "better-auth/plugins";
// Inside betterAuth configuration:
plugins: [
organization({
async sendInvitationEmail(data) { // ← 'data' parameter loses type with ts-go
// TypeScript should infer a complex type for 'data' from the plugin's type definitions
...
},
}),
]
TypeScript configuration:
{
"compilerOptions": {
"target": "ES2017",
"strict": true,
"esModuleInterop": true,
"moduleResolution": "bundler"
}
}
Behavior with typescript@5.9.3
Using the standard TypeScript LSP (VSCode), the data parameter is correctly inferred with this complete type:
sendInvitationEmail(data: {
id: string;
role: string;
email: string;
organization: {
id: string;
name: string;
slug: string;
createdAt: Date;
logo?: string | null | undefined;
metadata?: any;
};
invitation: {
id: string;
organizationId: string;
email: string;
role: string;
status: "pending" | "accepted" | "rejected" | "canceled";
inviterId: string;
expiresAt: Date;
createdAt: Date;
teamId?: string | null | undefined;
};
inviter: {
id: string;
organizationId: string;
userId: string;
role: string;
createdAt: Date;
} & {
user: {
id: string;
createdAt: Date;
updatedAt: Date;
email: string;
emailVerified: boolean;
name: string;
image?: string | ... 1 more ... | undefined;
};
};
}): Promise<void>
The IDE provides full autocomplete and type checking for data.email, data.inviter.user.name, data.organization.name, etc.
Behavior with tsgo
When using ts-go's LSP, the data parameter is inferred as any, resulting in:
- Loss of autocomplete for all properties
- Loss of type safety
- No errors when accessing non-existent properties
This appears to be a regression in type inference for callback parameters where the type should be inferred from the plugin's type definition (from the better-auth/plugins package).
Additional context
- Environment: VSCode with ts-go LSP
- Library:
better-auth@^1.4.3 with TypeScript type definitions
- Impact: This affects developer experience significantly, as callback parameters in plugin configurations lose all type information
- Pattern: The issue occurs with callback functions passed as options to plugin configuration functions where the callback parameter type should be inferred from the plugin's type signature
The type information is available in the better-auth/plugins package type definitions, but ts-go seems unable to propagate it to the callback parameter.
Steps to reproduce
This issue occurs in the better-auth Next.js demo, specifically in the
organizationplugin callback.Original Repository: https://github.com/better-auth/better-auth/tree/main/demo/nextjs
Repro (extracted demo folder with tsgo config, without any other changes): https://github.com/Azzerty23/tsgo-issue-repro
File:
lib/auth.ts, line 135Minimal reproduction:
TypeScript configuration:
{ "compilerOptions": { "target": "ES2017", "strict": true, "esModuleInterop": true, "moduleResolution": "bundler" } }Behavior with
typescript@5.9.3Using the standard TypeScript LSP (VSCode), the
dataparameter is correctly inferred with this complete type:The IDE provides full autocomplete and type checking for
data.email,data.inviter.user.name,data.organization.name, etc.Behavior with
tsgoWhen using ts-go's LSP, the
dataparameter is inferred asany, resulting in:This appears to be a regression in type inference for callback parameters where the type should be inferred from the plugin's type definition (from the
better-auth/pluginspackage).Additional context
better-auth@^1.4.3with TypeScript type definitionsThe type information is available in the
better-auth/pluginspackage type definitions, but ts-go seems unable to propagate it to the callback parameter.