diff options
author | 2022-09-23 13:27:07 -0400 | |
---|---|---|
committer | 2022-09-23 13:27:07 -0400 | |
commit | 49ca9e1291616b0cbe5544ae451ea6d1c79ba93b (patch) | |
tree | cfa4c29ddd8787bf491202176188cdeea3665bdb | |
parent | f4edba80f98a1b33db8ceacc3294466cefbf2d6b (diff) | |
download | astro-49ca9e1291616b0cbe5544ae451ea6d1c79ba93b.tar.gz astro-49ca9e1291616b0cbe5544ae451ea6d1c79ba93b.tar.zst astro-49ca9e1291616b0cbe5544ae451ea6d1c79ba93b.zip |
Define toStringTag another way (#4855)
* Define toStringTag another way
* Adding a changeset
-rw-r--r-- | .changeset/fluffy-doors-vanish.md | 5 | ||||
-rw-r--r-- | packages/astro/src/runtime/server/escape.ts | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/.changeset/fluffy-doors-vanish.md b/.changeset/fluffy-doors-vanish.md new file mode 100644 index 000000000..ad458c0cc --- /dev/null +++ b/.changeset/fluffy-doors-vanish.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix TS errors when not using skipLibCheck diff --git a/packages/astro/src/runtime/server/escape.ts b/packages/astro/src/runtime/server/escape.ts index ebba8e132..d6cd1de4a 100644 --- a/packages/astro/src/runtime/server/escape.ts +++ b/packages/astro/src/runtime/server/escape.ts @@ -3,12 +3,15 @@ import { escape } from 'html-escaper'; // Leverage the battle-tested `html-escaper` npm package. export const escapeHTML = escape; -export class HTMLBytes extends Uint8Array { - // @ts-ignore - get [Symbol.toStringTag]() { +export class HTMLBytes extends Uint8Array {} + +// TypeScript won't let us define this in the class body so have to do it +// this way. Boo. +Object.defineProperty(HTMLBytes.prototype, Symbol.toStringTag, { + get() { return 'HTMLBytes'; } -} +}); /** * A "blessed" extension of String that tells Astro that the string |