generic type library of arrive package.
npm install arrive
npm install @dragonish/arrive-type -DThis package ships global type declarations (it augments Document, Window, Element, JQuery, etc.), so TypeScript needs to load it. Choose one of the following methods.
Add this to a global declaration file in your project (e.g. src/vite-env.d.ts or global.d.ts):
/// <reference types="@dragonish/arrive-type" />- Leaves other compiler options untouched.
- Keeps automatic
@types/*inclusion working. - Resolves correctly in monorepo sub-packages.
Add to tsconfig.json:
{
"compilerOptions": {
"types": ["@dragonish/arrive-type"]
}
}Note: once
typesis set, other@types/*packages are no longer included automatically; list them as well (e.g.["@dragonish/arrive-type", "node", "vite/client"]). If your project already definestypes, merge rather than overwrite.
Add to tsconfig.json:
{
"compilerOptions": {
"typeRoots": [
"./node_modules/@types",
"./node_modules/@dragonish"
]
}
}This method has several limitations and is not recommended unless your project already uses
typeRoots:
- If
typesis also set, this method has no effect (TypeScript stops scanningtypeRoots).- In sub-packages, monorepos, or hoisted dependencies, the relative
./node_modulespath may fail to resolve.- It registers every package under the
@dragonishscope as a global type.
document.arrive<HTMLImageElement>('img', img => {
const src = img.src;
// ...
});Async/await and promise support:
const img = await document.arrive<HTMLImageElement>('img');
const src = img.src;
// ...