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
21 lines
574 B
TypeScript
21 lines
574 B
TypeScript
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),
|
|
}));
|
|
}
|