dependencies: Patch handlebars to declare its types correctly.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-11-11 00:38:36 -08:00 committed by Tim Abbott
parent a297ce7371
commit 4e8d028c49
4 changed files with 68 additions and 7 deletions

View File

@ -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"

57
patches/handlebars.patch Normal file
View File

@ -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<T = any> {
(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;

View File

@ -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

View File

@ -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