{"_id":"@poppinss/types","_rev":"3-104fa0615ad823f7e41823f86aa0abee","name":"@poppinss/types","dist-tags":{"latest":"1.2.1"},"versions":{"1.1.0":{"name":"@poppinss/types","version":"1.1.0","keywords":[],"author":{"name":"Harminder Virk","email":"virk@adonisjs.com"},"license":"MIT","_id":"@poppinss/types@1.1.0","maintainers":[{"name":"virk","email":"virk@adonisjs.com"},{"name":"romainlanz","email":"romain.lanz+npm@pm.me"},{"name":"julien-r44","email":"julien@ripouteau.com"}],"homepage":"https://github.com/poppinss/types#readme","bugs":{"url":"https://github.com/poppinss/types/issues"},"c8":{"exclude":["tests/**"],"reporter":["text","html"]},"dist":{"shasum":"86c11b6531d647d5136aa18c31bc899f171b90dd","tarball":"https://registry.npmjs.org/@poppinss/types/-/types-1.1.0.tgz","fileCount":9,"integrity":"sha512-EJVSxmoU2VO2z9rYc2fvrsYVO5mt/FGjdIShk6tVAFD4G+QBcs6gAYKQa+gvIu87J8YgUYVBYTfi/FnDzdfveg==","signatures":[{"sig":"MEUCIQD8KamQs09phBg9s6Tg2fUt9lurAvFUH4qzTqlRUcRqEQIgGI/4gbJhEzUx1CkEUG8ON2INig8suI/YQTwyiajmgC0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@poppinss%2ftypes@1.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":17191},"main":"build/index.js","type":"module","types":"./build/index.d.ts","exports":{".":"./build/index.js"},"gitHead":"2c936bf5bf18feafc8dd271908cf0d0940839111","scripts":{"lint":"eslint .","test":"c8 npm run quick:test","build":"npm run compile","format":"prettier --write .","compile":"tsc","pretest":"npm run lint","release":"release-it","version":"npm run build","typecheck":"tsc --noEmit","precompile":"npm run lint","quick:test":"node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"virk","email":"virk@adonisjs.com"},"prettier":"@adonisjs/prettier-config","release-it":{"git":{"push":true,"tagName":"v${version}","commitMessage":"chore(release): ${version}","tagAnnotation":"v${version}","requireUpstream":true,"requireCleanWorkingDir":true},"npm":{"publish":true,"skipChecks":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":{"name":"angular"}}}},"repository":{"url":"git+https://github.com/poppinss/types.git","type":"git"},"_npmVersion":"10.8.2","description":"A collection of types-only helpers used across all the AdonisJS, Edge, VineJS, and Japa packages","directories":{},"_nodeVersion":"20.19.1","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","eslint":"^9.27.0","prettier":"^3.5.3","release-it":"^19.0.2","typescript":"^5.8.3","@types/node":"^22.15.18","@japa/assert":"^4.0.1","@japa/runner":"^4.2.0","@japa/expect-type":"^2.0.3","@japa/file-system":"^2.3.2","@poppinss/ts-exec":"^1.1.5","@adonisjs/tsconfig":"^1.4.0","@adonisjs/eslint-config":"^2.0.0","@adonisjs/prettier-config":"^1.4.4","@release-it/conventional-changelog":"^10.0.1"},"_npmOperationalInternal":{"tmp":"tmp/types_1.1.0_1747552564743_0.9944226409206205","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@poppinss/types","version":"1.2.0","keywords":[],"author":{"name":"Harminder Virk","email":"virk@adonisjs.com"},"license":"MIT","_id":"@poppinss/types@1.2.0","maintainers":[{"name":"virk","email":"virk@adonisjs.com"},{"name":"romainlanz","email":"romain.lanz+npm@pm.me"},{"name":"julien-r44","email":"julien@ripouteau.com"}],"homepage":"https://github.com/poppinss/types#readme","bugs":{"url":"https://github.com/poppinss/types/issues"},"c8":{"exclude":["tests/**"],"reporter":["text","html"]},"dist":{"shasum":"a21ce2fcb4be31a6d36c51c25dd71c51f017c30a","tarball":"https://registry.npmjs.org/@poppinss/types/-/types-1.2.0.tgz","fileCount":9,"integrity":"sha512-kHwS1lDC/IQeqaBEbuJuWNVt46OGdQQN6+wvyq+GFa2YWV33TAGDku7dkeXDSxddt6UX+URWCLsJ+JRJWCCZLQ==","signatures":[{"sig":"MEUCIQD7vlfp50lIiXIlPVDDpO6NPD/k59Ages2UUpg6wPizKQIgDcsfpGrU7VdNGB67lKOedSG8vGN1mrIxuqL30oCmBgU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@poppinss%2ftypes@1.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":17725},"main":"build/index.js","type":"module","types":"./build/index.d.ts","exports":{".":"./build/index.js"},"gitHead":"4c579507f2e7c8860ac2486aa799e1a84ded9c16","scripts":{"lint":"eslint .","test":"c8 npm run quick:test","build":"npm run compile","format":"prettier --write .","compile":"tsc","pretest":"npm run lint","release":"release-it","version":"npm run build","typecheck":"tsc --noEmit","precompile":"npm run lint","quick:test":"node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"virk","email":"virk@adonisjs.com"},"prettier":"@adonisjs/prettier-config","release-it":{"git":{"push":true,"tagName":"v${version}","commitMessage":"chore(release): ${version}","tagAnnotation":"v${version}","requireUpstream":true,"requireCleanWorkingDir":true},"npm":{"publish":true,"skipChecks":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":{"name":"angular"}}}},"repository":{"url":"git+https://github.com/poppinss/types.git","type":"git"},"_npmVersion":"11.5.1","description":"A collection of types-only helpers used across all the AdonisJS, Edge, VineJS, and Japa packages","directories":{},"_nodeVersion":"24.7.0","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","eslint":"^9.34.0","prettier":"^3.6.2","release-it":"^19.0.4","typescript":"^5.9.2","@types/node":"^24.3.0","@japa/assert":"^4.1.1","@japa/runner":"^4.4.0","@japa/expect-type":"^2.0.3","@japa/file-system":"^2.3.2","@poppinss/ts-exec":"^1.4.1","@adonisjs/tsconfig":"^2.0.0-next.0","@adonisjs/eslint-config":"^3.0.0-next.1","@adonisjs/prettier-config":"^1.4.5","@release-it/conventional-changelog":"^10.0.1"},"_npmOperationalInternal":{"tmp":"tmp/types_1.2.0_1756615743634_0.33195197561293344","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@poppinss/types","description":"A collection of types-only helpers used across all the AdonisJS, Edge, VineJS, and Japa packages","version":"1.2.1","type":"module","main":"build/index.js","exports":{".":"./build/index.js"},"scripts":{"pretest":"npm run lint","test":"c8 npm run quick:test","lint":"eslint .","format":"prettier --write .","typecheck":"tsc --noEmit","precompile":"npm run lint","compile":"tsc","build":"npm run compile","version":"npm run build","prepublishOnly":"npm run build","release":"release-it","quick:test":"node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts"},"devDependencies":{"@adonisjs/eslint-config":"^3.0.0-next.1","@adonisjs/prettier-config":"^1.4.5","@adonisjs/tsconfig":"^2.0.0-next.0","@ark/attest":"^0.55.0","@japa/assert":"^4.1.1","@japa/expect-type":"^2.0.3","@japa/file-system":"^2.3.2","@japa/runner":"^4.4.0","@poppinss/ts-exec":"^1.4.1","@release-it/conventional-changelog":"^10.0.2","@types/node":"^24.10.1","c8":"^10.1.3","eslint":"^9.39.1","prettier":"^3.7.3","release-it":"^19.0.6","typescript":"^5.9.3"},"homepage":"https://github.com/poppinss/types#readme","repository":{"type":"git","url":"git+https://github.com/poppinss/types.git"},"bugs":{"url":"https://github.com/poppinss/types/issues"},"keywords":[],"author":{"name":"Harminder Virk","email":"virk@adonisjs.com"},"license":"MIT","publishConfig":{"access":"public","provenance":true},"release-it":{"git":{"requireCleanWorkingDir":true,"requireUpstream":true,"commitMessage":"chore(release): ${version}","tagAnnotation":"v${version}","push":true,"tagName":"v${version}"},"github":{"release":true},"npm":{"publish":true,"skipChecks":true},"plugins":{"@release-it/conventional-changelog":{"preset":{"name":"angular"}}}},"c8":{"reporter":["text","html"],"exclude":["tests/**"]},"prettier":"@adonisjs/prettier-config","gitHead":"a4a0f8de54229dc6fb8bd6b7aeeb5cd3f8fd1387","types":"./build/index.d.ts","_id":"@poppinss/types@1.2.1","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-qUYnzl0m9HJTWsXtr8Xo7CwDx6wcjrvo14bOVbIMIlKJCzKrm3LX55dRTDr1/x4PpSvKVgmxvC6Ly2YiqXKOvQ==","shasum":"8801002d3a8fa4f411bc43cbee303b1c555b7271","tarball":"https://registry.npmjs.org/@poppinss/types/-/types-1.2.1.tgz","fileCount":15,"unpackedSize":18332,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@poppinss%2ftypes@1.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEA3meZAV+sdvufTbJXPJfOuyYlU46d3BlDkN5fHvkTmAiEAuasv53yn8rGIDOyKBDFNRHc5XwqxcQxZw+aSnYIr/OY="}]},"_npmUser":{"name":"virk","email":"virk@adonisjs.com"},"directories":{},"maintainers":[{"name":"virk","email":"virk@adonisjs.com"},{"name":"romainlanz","email":"romain.lanz+npm@pm.me"},{"name":"julien-r44","email":"julien@ripouteau.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/types_1.2.1_1764579055925_0.30540257449066144"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-18T07:16:04.642Z","modified":"2025-12-01T08:50:56.593Z","1.1.0":"2025-05-18T07:16:04.928Z","1.2.0":"2025-08-31T04:49:03.843Z","1.2.1":"2025-12-01T08:50:56.124Z"},"bugs":{"url":"https://github.com/poppinss/types/issues"},"author":{"name":"Harminder Virk","email":"virk@adonisjs.com"},"license":"MIT","homepage":"https://github.com/poppinss/types#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/poppinss/types.git"},"description":"A collection of types-only helpers used across all the AdonisJS, Edge, VineJS, and Japa packages","maintainers":[{"name":"virk","email":"virk@adonisjs.com"},{"name":"romainlanz","email":"romain.lanz+npm@pm.me"},{"name":"julien-r44","email":"julien@ripouteau.com"}],"readme":"# @poppinss/types\n\n> A collection of types-only helpers used across all the AdonisJS, Edge, VineJS, and Japa packages\n\n<br />\n\n[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]\n\n## Usage\n\nThis package contains types-only helpers with no runtime code. You can install it from the npm packages registry.\n\n```sh\nnpm i @poppinss/types\n```\n\n## Helpers\n\nFollowing is the list of available helpers\n\n### `InferRouteParams<Identifier>`\n\nInfer params of a route pattern. Helper supports the AdonisJS routing syntax only.\n\n```ts\nimport type { InferRouteParams } from '@poppinss/types'\n\nInferRouteParams<'/users'> // {}\nInferRouteParams<'/users/:id'> // { id: string }\nInferRouteParams<'/users/:id?'> // { id?: string }\nInferRouteParams<'/users/:id/:slug?'> // { id: string; slug?: string }\nInferRouteParams<'/users/:id.json'> // { id: string }\nInferRouteParams<'/users/*'> // { '*': string[] }\nInferRouteParams<'/posts/:category/*'> // { 'category': string; '*': string[] }\n```\n\n### `Prettify<T>`\n\nPrettifies the complex TypeScript types to a simplified type for a better viewing experience. For example:\n\n```ts\nimport type { Prettify } from '@poppinss/types'\nimport type { ExtractDefined, ExtractUndefined } from '@poppinss/types'\n\ntype Values = {\n  username: string | undefined\n  email: string\n  fullName: string | undefined\n  age: number | undefined\n}\n\n// When not using prettify helper\ntype WithUndefinedOptional = {\n  [K in ExtractDefined<Values>]: Values[K]\n} & {\n  [K in ExtractUndefined<Values>]: Values[K]\n}\n\n// When using prettify helper\ntype WithUndefinedOptionalPrettified = Prettify<\n  {\n    [K in ExtractDefined<Values>]: Values[K]\n  } & {\n    [K in ExtractUndefined<Values>]: Values[K]\n  }\n>\n```\n\n![](./assets/not-prettified.png)\n![](./assets/prettified.png)\n\n### `Primitive`\n\nUnion of primitive types. It includes `null | undefined | string | number | boolean | symbol | bigint`\n\n```ts\nimport type { Primitive } from '@poppinss/types'\n\nfunction serialize(\n  values:\n    | Primitive\n    | Record<string, Primitive | Primitive[]>\n    | Primitive[]\n    | Record<string, Primitive | Primitive[]>[]\n) {}\n```\n\n### `OneOrMore<T>`\n\nSpecify a union that accepts either `T` or `T[]`.\n\n```ts\nimport type { OneOrMore } from '@poppinss/types'\nimport type { Primitive } from '@poppinss/types'\n\nfunction serialize(\n  values: OneOrMore<Primitive> | OneOrMore<Record<string, Primitive | Primitive[]>>\n) {}\n```\n\n### `Constructor<T, Arguments>`\n\nRepresent a class constructor. The `T` refers to the class instance properties, and `Arguments` refers to the constructor arguments.\n\n```ts\nimport type { Constructor } from '@poppinss/types'\n\nfunction make<Args extends any[]>(Klass: Constructor<any, Args>, ...args: Args) {\n  return new Klass(...args)\n}\n```\n\n### `AbstractConstructor<T, Arguments>`\n\nRepresent a class constructor that could also be abstract. The `T` refers to the class instance properties, and `Arguments` refers to the constructor arguments.\n\n```ts\nimport type { AbstractConstructor } from '@poppinss/types'\nfunction log<Args extends any[]>(Klass: AbstractConstructor<any, Args>, ...args: Args) {}\n```\n\n### `LazyImport<DefaultExport>`\n\nRepresent a function that lazily imports a module with `export default`.\n\n```ts\nimport type { LazyImport, Constructor } from '@poppinss/types'\n\nfunction middleware(list: LazyImport<Constructor<{ handle(): any }>>[]) {}\n```\n\n### `UnWrapLazyImport<Fn>`\n\nUnwrap the default export of a `LazyImport` function.\n\n```ts\nimport type { LazyImport, UnWrapLazyImport } from '@poppinss/types'\n\ntype Middleware = LazyImport<Constructor<{ handle(): any }>>\ntype MiddlewareClass = UnWrapLazyImport<Middleware>\n```\n\n### `NormalizeConstructor<T>`\n\nNormalizes the constructor arguments of a class for use with mixins. The helper is created to work around [TypeScript issue#37142](https://github.com/microsoft/TypeScript/issues/37142).\n\n**Usage without NormalizeConstructor**\n\n```ts\nclass Base {}\n\nfunction DatesMixin<TBase extends typeof Base>(superclass: TBase) {\n  // A mixin class must have a constructor with a single rest parameter of type 'any[]'. ts(2545)\n  return class HasDates extends superclass {\n    //          ❌ ^^\n    declare createdAt: Date\n    declare updatedAt: Date\n  }\n}\n\n// Base constructors must all have the same return type.ts(2510)\nclass User extends DatesMixin(Base) {}\n//                    ❌ ^^\n```\n\n**Using NormalizeConstructor**\n\n```ts\nimport type { NormalizeConstructor } from '@poppinss/types'\n\nclass Base {}\n\nfunction DatesMixin<TBase extends NormalizeConstructor<typeof Base>>(superclass: TBase) {\n  return class HasDates extends superclass {\n    declare createdAt: Date\n    declare updatedAt: Date\n  }\n}\n\nclass User extends DatesMixin(Base) {}\n```\n\n### `Opaque<T>`\n\nDefine an opaque type to distinguish between similar properties.\n\n```ts\nimport type { Opaque } from '@poppinss/types'\n\ntype Username = Opaque<string, 'username'>\ntype Password = Opaque<string, 'password'>\n\nfunction checkUser(_: Username) {}\n\n// ❌ Argument of type 'string' is not assignable to parameter of type 'Opaque<string, \"username\">'.\ncheckUser('hello')\n\n// ❌ Argument of type 'Opaque<string, \"password\">' is not assignable to parameter of type 'Opaque<string, \"username\">'.\ncheckUser('hello' as Password)\n\ncheckUser('hello' as Username)\n```\n\n### `UnwrapOpaque<T>`\n\nUnwrap the value from an opaque type.\n\n```ts\nimport type { Opaque, UnwrapOpaque } from '@poppinss/types'\n\ntype Username = Opaque<string, 'username'>\ntype Password = Opaque<string, 'password'>\n\ntype UsernameValue = UnwrapOpaque<Username> // string\ntype PasswordValue = UnwrapOpaque<Password> // string\n```\n\n### `ExtractFunctions<T, IgnoreList>`\n\nExtract all the functions from an object. Optionally specify a list of methods to ignore.\n\n```ts\nimport type { ExtractFunctions } from '@poppinss/types'\n\nclass User {\n  declare id: number\n  declare username: string\n\n  create() {}\n  update(_id: number, __attributes: any) {}\n}\n\ntype UserMethods = ExtractFunctions<User> // 'create' | 'update'\n```\n\nYou may use the `IgnoreList` to ignore methods from a known parent class\n\n```ts\nimport type { ExtractFunctions } from '@poppinss/types'\n\nclass Base {\n  save() {}\n}\n\nclass User extends Base {\n  declare id: number\n  declare username: string\n\n  create() {}\n  update(_id: number, __attributes: any) {}\n}\n\ntype UserMethods = ExtractFunctions<User> // 'create' | 'update' | 'save'\ntype UserMethodsWithParent = ExtractFunctions<User, ExtractFunctions<Base>> // 'create' | 'update'\n```\n\n### `AreAllOptional<T>`\n\nCheck if all the top-level properties of an object are optional.\n\n```ts\nimport type { AreAllOptional } from '@poppinss/types'\n\nAreAllOptional<{ id: string; name?: string }> // false\nAreAllOptional<{ id?: string; name?: string }> // true\n```\n\n### `ExtractUndefined<T>`\n\nExtract properties that are `undefined` or are a union with `undefined` values.\n\n```ts\nimport type { ExtractUndefined } from '@poppinss/types'\n\ntype UndefinedProperties = ExtractUndefined<{ id: string; name: string | undefined }>\n```\n\n### `ExtractDefined<T>`\n\nExtract properties that are not `undefined` nor is a union with `undefined` values.\n\n```ts\nimport type { ExtractDefined } from '@poppinss/types'\n\ntype UndefinedProperties = ExtractDefined<{ id: string; name: string | undefined }>\n```\n\n### `AsyncOrSync<T>`\n\nDefine a union with the value or a `PromiseLike` of the value.\n\n```ts\nimport type { AsyncOrSync } from '@poppinss/types'\n\nfunction log(fetcher: () => AsyncOrSync<{ id: number }>) {\n  const { id } = await fetcher()\n}\n```\n\n### `DeepPartial<T>`\n\nMark nested properties as partial until unlimited depth.\n\n```ts\nimport type { DeepPartial } from '@poppinss/types'\n\ntype Config = {\n  http: {\n    bodyParser: {\n      enabled: boolean\n    }\n    qs: {\n      parse: {\n        quotes: boolean\n      }\n    }\n  }\n}\n\nexport function defineConfig(config: DeepPartial<Config>): Config {}\n```\n\n## Contributing\n\nOne of the primary goals of Poppinss is to have a vibrant community of users and contributors who believes in the principles of the framework.\n\nWe encourage you to read the [contribution guide](https://github.com/poppinss/.github/blob/main/docs/CONTRIBUTING.md) before contributing to the framework.\n\n## Code of Conduct\n\nIn order to ensure that the Poppinss community is welcoming to all, please review and abide by the [Code of Conduct](https://github.com/poppinss/.github/blob/main/docs/CODE_OF_CONDUCT.md).\n\n## License\n\n@poppinss/types is open-sourced software licensed under the [MIT license](LICENSE.md).\n\n[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/poppinss/types/checks.yml?style=for-the-badge\n[gh-workflow-url]: https://github.com/poppinss/types/actions/workflows/checks.yml 'Github action'\n[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript\n[typescript-url]: \"typescript\"\n[npm-image]: https://img.shields.io/npm/v/@poppinss/types.svg?style=for-the-badge&logo=npm\n[npm-url]: https://npmjs.org/package/@poppinss/types 'npm'\n[license-image]: https://img.shields.io/npm/l/@poppinss/types?color=blueviolet&style=for-the-badge\n[license-url]: LICENSE.md 'license'\n","readmeFilename":"README.md"}