chore: Move to Typescript (#2783)
This PR moves the entire project to Typescript. Due to the ~1000 ignores this will lead to a messy codebase for a while, but the churn is worth it – all of those ignore comments are places that were never type-safe previously. closes #1282
This commit is contained in:
20
server/presenters/policy.ts
Normal file
20
server/presenters/policy.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { User } from "@server/models";
|
||||
|
||||
type Policy = {
|
||||
id: string;
|
||||
abilities: Record<string, boolean>;
|
||||
};
|
||||
|
||||
export default function present(
|
||||
// @ts-expect-error ts-migrate(2749) FIXME: 'User' refers to a value, but is being used as a t... Remove this comment to see the full error message
|
||||
user: User,
|
||||
objects: Record<string, any>[]
|
||||
): Policy[] {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { serialize } = require("../policies");
|
||||
|
||||
return objects.map((object) => ({
|
||||
id: object.id,
|
||||
abilities: serialize(user, object),
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user