From 4e8d028c49ea1757f62b884ec45c8c3aa0cde255 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 11 Nov 2024 00:38:36 -0800 Subject: [PATCH] dependencies: Patch handlebars to declare its types correctly. Signed-off-by: Anders Kaseorg --- package.json | 1 + patches/handlebars.patch | 57 ++++++++++++++++++++++++++++++++++++++++ pnpm-lock.yaml | 15 ++++++----- version.py | 2 +- 4 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 patches/handlebars.patch diff --git a/package.json b/package.json index 08a77eef81..17a4b1b2a3 100644 --- a/package.json +++ b/package.json @@ -160,6 +160,7 @@ "source-map@^0.6": "npm:source-map-js@^1.2.1" }, "patchedDependencies": { + "handlebars": "patches/handlebars.patch", "source-sans@3.46.0": "patches/source-sans@3.46.0.patch", "svgicons2svgfont": "patches/svgicons2svgfont.patch", "tippy.js@6.3.7": "patches/tippy.js@6.3.7.patch" diff --git a/patches/handlebars.patch b/patches/handlebars.patch new file mode 100644 index 0000000000..b0ce5db1ac --- /dev/null +++ b/patches/handlebars.patch @@ -0,0 +1,57 @@ +diff --git a/runtime.d.ts b/runtime.d.ts +index 0d5105eb73794b7ab88a7c30502977d10a836f45..a8e8768addd7c424eb8e82372eb3d955582eb456 100644 +--- a/runtime.d.ts ++++ b/runtime.d.ts +@@ -1,5 +1,3 @@ + import Handlebars = require('handlebars') + +-declare module "handlebars/runtime" { +- +-} +\ No newline at end of file ++export = Handlebars; +diff --git a/types/index.d.ts b/types/index.d.ts +index 3f2f8b792edbd621d06c399ff4c722234f233742..3b3d8cb0d3c9f264b00104c3ea0ba96a2e63d485 100644 +--- a/types/index.d.ts ++++ b/types/index.d.ts +@@ -14,7 +14,8 @@ + */ + // TypeScript Version: 2.3 + +-declare namespace Handlebars { ++declare global { ++namespace Handlebars { + export interface TemplateDelegate { + (context: T, options?: RuntimeOptions): string; + } +@@ -243,7 +244,7 @@ interface PrecompileOptions extends CompileOptions { + destName?: string; + } + +-declare namespace hbs { ++namespace hbs { + // for backward compatibility of this typing + type SafeString = Handlebars.SafeString; + +@@ -264,7 +265,7 @@ interface Logger { + + type CompilerInfo = [number/* revision */, string /* versions */]; + +-declare namespace hbs { ++namespace hbs { + namespace AST { + interface Node { + type: string; +@@ -412,11 +413,6 @@ declare namespace hbs { + } + } + } +- +-declare module "handlebars" { +- export = Handlebars; + } + +-declare module "handlebars/runtime" { +- export = Handlebars; +-} ++export = Handlebars; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f5ea0f0703..63f032fbc6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ overrides: source-map@^0.6: npm:source-map-js@^1.2.1 patchedDependencies: + handlebars: + hash: c5t5wnxp6mvabdrpn7wm4zt2zu + path: patches/handlebars.patch source-sans@3.46.0: hash: 4n7ij66tzyhzaqnxsenbilrxr4 path: patches/source-sans@3.46.0.patch @@ -147,10 +150,10 @@ importers: version: 1.2.0 handlebars: specifier: ^4.7.2 - version: 4.7.8 + version: 4.7.8(patch_hash=c5t5wnxp6mvabdrpn7wm4zt2zu) handlebars-loader: specifier: ^1.7.1 - version: 1.7.3(handlebars@4.7.8) + version: 1.7.3(handlebars@4.7.8(patch_hash=c5t5wnxp6mvabdrpn7wm4zt2zu)) html-webpack-plugin: specifier: ^5.3.2 version: 5.6.3(webpack@5.96.1) @@ -11600,7 +11603,7 @@ snapshots: '@vusion/webfonts-generator@0.8.0': dependencies: - handlebars: 4.7.8 + handlebars: 4.7.8(patch_hash=c5t5wnxp6mvabdrpn7wm4zt2zu) mkdirp: 1.0.4 q: 1.5.1 svg2ttf: 6.0.3 @@ -14310,15 +14313,15 @@ snapshots: handle-thing@2.0.1: {} - handlebars-loader@1.7.3(handlebars@4.7.8): + handlebars-loader@1.7.3(handlebars@4.7.8(patch_hash=c5t5wnxp6mvabdrpn7wm4zt2zu)): dependencies: async: 3.2.6 fastparse: 1.1.2 - handlebars: 4.7.8 + handlebars: 4.7.8(patch_hash=c5t5wnxp6mvabdrpn7wm4zt2zu) loader-utils: 1.4.2 object-assign: 4.1.1 - handlebars@4.7.8: + handlebars@4.7.8(patch_hash=c5t5wnxp6mvabdrpn7wm4zt2zu): dependencies: minimist: 1.2.8 neo-async: 2.6.2 diff --git a/version.py b/version.py index 1a62d30157..fd5e9c3abb 100644 --- a/version.py +++ b/version.py @@ -49,4 +49,4 @@ API_FEATURE_LEVEL = 319 # Last bumped for message-link class # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = (301, 1) # bumped 2024-11-12 to add types for Google analytics +PROVISION_VERSION = (301, 2) # bumped 2024-11-12 to patch handlebars