{"id":14007184,"url":"https://github.com/bkper/clasp-types","last_synced_at":"2026-01-22T17:24:44.011Z","repository":{"id":37317365,"uuid":"207030393","full_name":"bkper/clasp-types","owner":"bkper","description":"A d.ts generator for clasp projects","archived":false,"fork":false,"pushed_at":"2025-12-02T17:54:29.000Z","size":704,"stargazers_count":20,"open_issues_count":10,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-13T20:06:21.510Z","etag":null,"topics":["clasp","google-apps-script","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bkper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-07T21:59:51.000Z","updated_at":"2025-12-02T17:54:31.000Z","dependencies_parsed_at":"2022-09-16T15:01:25.981Z","dependency_job_id":null,"html_url":"https://github.com/bkper/clasp-types","commit_stats":null,"previous_names":["maelcaldas/clasp-types"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/bkper/clasp-types","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkper%2Fclasp-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkper%2Fclasp-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkper%2Fclasp-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkper%2Fclasp-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bkper","download_url":"https://codeload.github.com/bkper/clasp-types/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkper%2Fclasp-types/sbom","scorecard":{"id":241724,"data":{"date":"2025-08-11","repo":{"name":"github.com/bkper/clasp-types","commit":"4502cfcf7baa715b81e393afb694e60ba3aaa479"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"25 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-vfrc-7r7c-w9mx","Warn: Project is vulnerable to: GHSA-7wwv-vh3v-89cq","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj","Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-px4h-xg32-q955","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6","Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T06:47:11.093Z","repository_id":37317365,"created_at":"2025-08-17T06:47:11.094Z","updated_at":"2025-08-17T06:47:11.094Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28667699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T17:07:18.858Z","status":"ssl_error","status_checked_at":"2026-01-22T17:05:02.040Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["clasp","google-apps-script","typescript"],"created_at":"2024-08-10T10:01:53.257Z","updated_at":"2026-01-22T17:24:43.977Z","avatar_url":"https://github.com/bkper.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"[BkperApp]: https://github.com/bkper/bkper-app\n[API Extractor]: https://api-extractor.com/\n[grant]: https://github.com/grant/google-apps-script-dts\n[motemen]: https://github.com/motemen/dts-google-apps-script\n[mtgto]: https://github.com/mtgto/dts-google-apps-script-advanced\n[Add-on for Google Sheets]: https://workspace.google.com/marketplace/app/bkper/360398463400s\n[HTML Service]: https://developers.google.com/apps-script/guides/html/communication\n[Libraries]: https://developers.google.com/apps-script/guides/libraries\n[library]: https://developers.google.com/apps-script/guides/libraries\n[Client-side API]: https://developers.google.com/apps-script/guides/html/reference/run\n[clasp]: https://github.com/google/clasp\n[TypeScript]: https://github.com/google/clasp/blob/master/docs/typescript.md\n[inline-source-cli]: https://www.npmjs.com/package/inline-source-cli\n[glob-exec]: https://www.npmjs.com/package/glob-exec\n[DefinitelyTyped]: http://definitelytyped.org/\n[example]: https://www.npmjs.com/package/@bkper/bkper-app-types\n\n# clasp-types\n\n[![npm](https://img.shields.io/npm/v/clasp-types)](https://www.npmjs.com/package/clasp-types)\n\nA [TypeScript] definitions generator for [clasp] projects to get **autocomplete** and **type checking** for your Google Apps Script Object Oriented [Libraries] and [Client-side API].\n\n*Library:*\n![library-autocomplete](https://raw.githubusercontent.com/bkper/clasp-types/master/imgs/library-autocomplete.png)\n\n*Client-side API:*\n![client-side-api-autocomplete](https://raw.githubusercontent.com/bkper/clasp-types/master/imgs/client-side-api-autocomplete.png)\n\nIt works like the [API Extractor], reading the ```@public``` comment annotations on any global function, class, interface or enum you want to expose, and generating d.ts files consistently.\n\n## Features\n\n- **d.ts rollup:** Generate a single ```d.ts``` from all your ```.ts``` files, wrapping global functions into Library interface.\n\n- **Clean library API:** Expose only functions and methods through ```@public``` annotation, building a cleanner interface and avoiding usage of elements not intended to be exposed.\n\n- **Publish ready:** Generate a npm package, with clear setup instructions, ready to be published.\n\n- **Client-side API** For Add-ons and Web Apps, generate types for your global functions exposed with ```@public```, in a single ```d.ts``` file on *@types* folder, to get autocomplete for the server API on client.\n\nHere is an [example] of library types built and published with clasp-types.\n\n\u003e Note: clasp-types is intended for generating d.ts from Apps Script code already written in TypeScript. For generating built-in and advanced Apps Script services see https://github.com/grant/google-apps-script-dts\n\n## Install\n\n```\nnpm i -S clasp-types\n```\nor\n```\nyarn add --dev clasp-types\n```\n\n## Command\n\n```\nclasp-types\n```\n\nOptional params:\n```sh\n--src          \u003cfolder\u003e    # default: ./src     - Source folder \n--out          \u003cfolder\u003e    # default: ./dist    - Output folder              \n--client                   # default: false     - Generate client side API types  \n--root         \u003cfolder\u003e    # default: ./        - Project root folder  \n```\n\n## Library setup\n\n\n### 1) Add your library *namespace* and *name* to the ```.clasp.json```:\n```json\n{\n  \"scriptId\": \"1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF\",\n  \"rootDir\": \"./src\",\n  \"library\": {\n    \"namespace\": \"gsuitedevs\",\n    \"name\": \"OAuth2\"\n  }\n}\n```\n\n### 2) Add ```@public``` comment annotation to the code you want to expose\n\n```ts\n/**\n * Create a service\n * \n * @public\n */\nfunction createService(serviceName: string) {\n  return new Service(serviceName);\n}\n\n/**\n * The OAuth service\n * \n * @public\n */\nclass Service {\n  name: string;\n  params_: any;\n  constructor(name: string) {\n    this.name = name;;\n  }\n\n  public getName() {\n    return this.name;\n  }\n  \n\n  /**\n   * Sets an additional parameter to use when constructing the authorization URL.\n   */\n  public setParam(name: string, value: string): Service {\n    this.params_[name] = value;\n    return this;\n  };\n\n}\n```\n\n### 3) Run ```clasp-types``` to generate a **npm package** with index.d.ts like:\n\n```ts\ndeclare namespace gsuitedevs {\n\n    /**\n     * The main entry point to interact with OAuth2\n     *\n     * Script ID: **1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF**\n     */\n    export interface OAuth2 {\n\n        /**\n         * Create a service\n         */\n        createService(serviceName: string): Service;\n\n    }\n\n    /**\n     * The OAuth service\n     */\n    export interface Service {\n\n        getName(): string;\n\n        /**\n         * Sets an additional parameter to use when constructing the authorization URL.\n         */\n        setParam(name: string, value: string): Service;\n\n    }\n\n}\n\ndeclare var OAuth2: gsuitedevs.OAuth2;\n```\n\n\u003e *Notes:* \n\u003e - On classes annotaded with ```@public```, methods inside then should also be marked as ```public``` in order to be exposed. **Private** or **protected** methods will **not** be exposed. \n\u003e - Interfaces and Enumerations with ```@public``` annotation will have all members exposed by default.\n\nA **npm ready to publish package** is generated in the output folder, with some setup instructions on **README.md**, so you can easily share your library types. Here is an [example].\n\n\u003e *Suggestion:* You may add a [dist-tag](https://docs.npmjs.com/cli/dist-tag) to your types package distribution with the same [version](https://developers.google.com/apps-script/guides/versions) of the script, say, ```v23```, so users can link the types version with script version, and use ones that matches.\n\n### Dependencies\n\nIf your package expose a transitive dependency on **params** or **return** types, such as GoogleAppsScript.HTML.HtmlOutput from @types/google-apps-script, add it to **\"dependencies\"** section of your package.json, instead of \"devDependencies\":\n```json\n  \"dependencies\": {\n    \"@types/google-apps-script\": \"^0.0.59\"\n  }\n```\nSo, clasp-types will correctly setup the reference on index.d.ts:\n\n ```ts\n /// \u003creference types=\"google-apps-script\" /\u003e\n ```\nAnd on the resulted package.json:\n```json\n  \"dependencies\": {\n    \"@types/google-apps-script\": \"*\"\n  },\n```\n\n\n\n## Client-side API setup\n\n### 1) Add ```@public``` comment annotation to the code you want to expose to client\n```ts\n/**\n * Execute a sum on server side, from client side\n * \n * @public\n */\nfunction sumOnServer(a: number, b: number): number {\n  return a + b;\n}\n```\n\n### 2) Run ```clasp-types --client``` to generate a index.d.ts like:\n\n```ts\ndeclare namespace google {\n\n    namespace script {\n\n        export interface Runner {\n\n            withSuccessHandler(handler: Function): Runner;\n\n            withFailureHandler(handler: (error: Error) =\u003e void): Runner;\n\n            withUserObject(object: any): Runner;\n\n            sumOnServer(a: number, b: number): void //number;\n            ...\n\n        }\n\n        export var run: Runner;\n\n    }\n    ...\n\n}\n```\n\n### TypeScript on Client-side\n\nTo develop with [TypeScript] on client side, you should work with separated ```ts``` files and inline the corresponding ```js```, as well as all ```css``` in the same page, in order to the resulting html template be processed by the [HTML Service].\n\nTo perform the inlining a great tool is the [inline-source-cli], so you can add a ```inline``` tag to your ```js``` and ```css``` references:\n\n```html\n\u003chead\u003e\n  ...\n  \u003clink inline href=\"page-style.css\" rel=\"stylesheet\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  ...\n  \u003cscript inline src=\"page-activity.js\"\u003e\u003c/script\u003e\n  \u003cscript inline src=\"page-view.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n```\nAnd then use a tool such as [glob-exec] to inline all your sources in one single script line:\n```sh\nglob-exec --foreach './build/**/*.html' --  'cat {{file}} | inline-source --root build \u003e dist/{{file.name}}{{file.ext}}'\n```\n\n## Background\n\nThe clasp-types was originally created as a foundation for the [BkperApp] library and the Bkper [Add-on for Google Sheets], with inspirations on the [API Extractor], [DefinitelyTyped] and previous work from [grant], [motemen] and [mtgto] - thank you guys :-)\n\n[Libraries] are a great way to share code between scripts, but, once published and others start using it, it requires some level of care like any other public API, so, applying some [API Extractor] concepts and principles help to keep the quality of the Library and avoid accidental breaks.\n\n[DefinitelyTyped] is an amazing initiative and works really well for publishing types for thirdy-party libraries written in js, as well as for the Google Apps Script built-in and advanced services, although, as its recommended in the [official declaration publishing documentation](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html), for libraries written in TypeScript, build its own npm package is favored, and give some advantages:\n\n- Instant publishing\n- Release automation\n- [Dist-tag](https://docs.npmjs.com/cli/dist-tag) for mapping script versions\n\nThe down side is that it requires one aditional aditional types configuration step, so, clasp-types automatically generate a package ready to publish, with instructions on README for scoped packages to setup the ```typeRoots``` and non scoped packages to setup the ```types```.\n\n\n## Help welcome\n\n- Identify edge cases for params and return types\n\n- Generate ```d.ts``` fom a well documented ```js``` library, so it can also work for libraries such as [OAuth2](https://github.com/gsuitedevs/apps-script-oauth2)\n\n- Generate client ```ts``` ([like this](https://github.com/google/apis-client-generator)) and ```d.ts``` from [openapi](https://swagger.io/specification/) and [API Discovery](https://developers.google.com/discovery/) specs, for [Advanced Services](https://developers.google.com/apps-script/guides/services/advanced) like libraries\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkper%2Fclasp-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbkper%2Fclasp-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkper%2Fclasp-types/lists"}