Define toStringTag another way (#4855)

* Define toStringTag another way

* Adding a changeset
This commit is contained in:
Matthew Phillips 2022-09-23 13:27:07 -04:00 committed by GitHub
parent f4edba80f9
commit 49ca9e1291
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix TS errors when not using skipLibCheck

View file

@ -3,12 +3,15 @@ import { escape } from 'html-escaper';
// Leverage the battle-tested `html-escaper` npm package. // Leverage the battle-tested `html-escaper` npm package.
export const escapeHTML = escape; export const escapeHTML = escape;
export class HTMLBytes extends Uint8Array { export class HTMLBytes extends Uint8Array {}
// @ts-ignore
get [Symbol.toStringTag]() { // 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'; return 'HTMLBytes';
} }
} });
/** /**
* A "blessed" extension of String that tells Astro that the string * A "blessed" extension of String that tells Astro that the string