{"id":34750977,"url":"https://github.com/ortima/ts-for-drupal-core","last_synced_at":"2026-04-19T22:34:43.043Z","repository":{"id":323831132,"uuid":"1094901798","full_name":"ortima/ts-for-drupal-core","owner":"ortima","description":"Drupal Core TypeScript definitions for frontend development","archived":false,"fork":false,"pushed_at":"2025-11-14T09:43:35.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"release/v0.0.7","last_synced_at":"2025-12-15T05:33:57.590Z","etag":null,"topics":["drupal","drupal-core","typescript","typescript-library"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ts-for-drupal-core","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ortima.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-12T10:23:25.000Z","updated_at":"2025-11-14T08:58:00.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ortima/ts-for-drupal-core","commit_stats":null,"previous_names":["ortima/ts-for-drupal-core","ortima/ts_for_drupal"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ortima/ts-for-drupal-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ortima%2Fts-for-drupal-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ortima%2Fts-for-drupal-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ortima%2Fts-for-drupal-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ortima%2Fts-for-drupal-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ortima","download_url":"https://codeload.github.com/ortima/ts-for-drupal-core/tar.gz/refs/heads/release/v0.0.7","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ortima%2Fts-for-drupal-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28020202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-25T02:00:05.988Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["drupal","drupal-core","typescript","typescript-library"],"created_at":"2025-12-25T05:13:53.695Z","updated_at":"2025-12-25T05:13:59.760Z","avatar_url":"https://github.com/ortima.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript definitions for Drupal core (forked)\n\nThis project is a **fork** of the original Drupal core TypeScript definitions, modified by ortima. It provides Drupal core TypeScript definitions for frontend development in Drupal projects.\n\n## Supporting Drupal core version\n\nDrupal 11\n\n## How to use\n\n1. Add this package to your devDependencies using a Node.js package manager like yarn or npm:\n   - `npm i -D ts-for-drupal-core`\n   - `yarn add -D ts-for-drupal-core`\n2. Configure TypeScript module settings to tsconfig.json like below.\n3. Add import type statement on your TypeScript code to load the Drupal core TypeScript definition.\n   The library definition is almost same as `core.libraries.yml` definition but **drupalSettings and once.js are not same.** See below example code.\n\nExample tsconfig.json:\n\n```jsonc\n{\n  \"compilerOptions\": {\n    \"module\": \"ESNext\",\n    \"moduleResolution\": \"Bundler\",\n}\n```\n\nExample code:\n\n```ts\n// Import each library definition.\nimport type {} from \"ts-for-drupal-core/drupal\";\nimport type {} from \"ts-for-drupal-core/drupal.ajax\";\n\n// The drupalSettings and once.js definitions are not same as the core library definitions.\nimport type {} from \"ts-for-drupal-core/drupal_settings\";\nimport type {} from \"ts-for-drupal-core/@drupal__once\";\n```\n\n### Actually used project\n\n- [Dialog Native](https://www.drupal.org/project/dialog_native)\n\n## Extends Drupal specific type\n\n### drupalSettings\n\n```ts\ndeclare global {\n  namespace drupalSettings {\n    const someVariable: string | number;\n  }\n}\n\n/*\n * If there is no export/import in a d.ts file, TS2669 error occurs by TypeScript.\n * See https://stackoverflow.com/questions/57132428/augmentations-for-the-global-scope-can-only-be-directly-nested-in-external-modul.\n */\nexport type {};\n```\n\n### Drupal.theme\n\n```ts\ndeclare global {\n  namespace Drupal {\n    namespace theme {\n      let someTheme: (arg1: string) =\u003e HTMLElement;\n    }\n  }\n}\n\nexport type {};\n```\n\n### A behavior with additional properties\n\n```ts\ndeclare global {\n  namespace Drupal {\n    interface behaviorAdditionalPropsMap {\n      someBehavior: {\n        additionalProp: Array\u003cstring\u003e;\n      };\n    }\n  }\n}\n\nexport type {};\n```\n\n### AjaxCommand\n\n```ts\nimport type { ajaxCommand } from \"drupal.ajax\";\n\ndeclare global {\n  namespace Drupal {\n    interface definedAjaxCommands {\n      someCommand: ajaxCommand\u003c\n        \"someCommand\",\n        {\n          arg1: number;\n          arg2: boolean;\n        },\n        string\n      \u003e;\n    }\n  }\n}\n```\n\n## FAQ\n\n### I don't want to write `ts-for-drupal-core/` prefix everytime.\n\n1. Create TypeScript base settings file named like tsconfig.base.json on the same directory which located the project package.json.\n2. Configure paths settings for tsconfig.base.json like below.\n3. Add `extends` settings to each tsconfig.json files, and load this base settings file.\n\nExample of tsconfig.base.json:\n\n```jsonc\n{\n  \"compilerOptions\": {\n    \"paths\": {\n      \"@drupal__once\": [\"./node_modules/ts-for-drupal-core/@drupal__once\"],\n      \"drupal_settings\": [\"./node_modules/ts-for-drupal-core/drupal_settings\"],\n      \"drupal.*\": [\"./node_modules/ts-for-drupal-core/drupal.*/\"],\n      \"drupal\": [\"./node_modules/ts-for-drupal-core/drupal\"]\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fortima%2Fts-for-drupal-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fortima%2Fts-for-drupal-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fortima%2Fts-for-drupal-core/lists"}