Skip to content

Commit

Permalink
Define toStringTag another way (#4855)
Browse files Browse the repository at this point in the history
* Define toStringTag another way

* Adding a changeset
  • Loading branch information
matthewp authored Sep 23, 2022
1 parent f4edba8 commit 49ca9e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-doors-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix TS errors when not using skipLibCheck
11 changes: 7 additions & 4 deletions packages/astro/src/runtime/server/escape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 49ca9e1

Please sign in to comment.