Skip to content
manifest / 1

TypeScript

Last updated:

On this page
php artisan manifest:types

The command does two things.

Import paths

It adds a paths entry to tsconfig.json for each package with a JS folder, and one for the Inertia helper:

{
  "compilerOptions": {
    "paths": {
      "@/*": ["./resources/js/*"],
      "@javaabu/manifest/inertia": ["./vendor/javaabu/manifest/dist/inertia.d.ts"],
      "@javaabu/filters": ["./vendor/javaabu/filters/resources/js"],
      "@javaabu/filters/*": ["./vendor/javaabu/filters/resources/js/*"]
    }
  }
}

Your own paths are kept. The paths are relative to baseUrl when you set one, and the file keeps two-space indentation if it had it. If tsconfig.json has comments, or isn't plain JSON, it's left alone and the paths are printed for you to paste. Without a tsconfig.json, they're printed too. Pass --no-tsconfig to skip this part.

Package files are type-checked as part of your project when you import them. To check all of them, add their folders to include:

"include": ["resources/js", "vendor/javaabu/*/resources/js"]

Page types

It writes resources/js/types/manifest.d.ts (or --path=), which tells @javaabu/manifest/inertia about every package page, with overrides applied:

// Generated by `php artisan manifest:types`. ...
import type {} from "@javaabu/manifest/inertia"

declare module "@javaabu/manifest/inertia" {
  interface PackagePages {
    "filters::Index": typeof import("../../../vendor/javaabu/filters/resources/js/Pages/Index")
    "filters::Reports/Show": typeof import("../../../resources/vendor/filters/js/Pages/Reports/Show")
  }
}

Then:

import { packagePage, type PackagePageModule, type PackagePageName } from "@javaabu/manifest/inertia"

const page: PackagePageName = "filters::Index"        // a union of every package page
packagePage("filters::Missing")                        // compile error

type ShowProps = Parameters<PackagePageModule<"filters::Reports/Show">["default"]>[0]

Make sure the file is included by your tsconfig.json (it is with "include": ["resources/js"]).

Run php artisan manifest:types again after installing, updating or overriding packages. Without the generated file, PackagePageName is string.

Vue files

Package .vue files need the usual shim in the app (declare module "*.vue"), or vue-tsc.

Documentation
All packages

javaabu/manifest

Source on GitHub