hackworthltd / primer-app

Primer's React frontend application.
GNU Affero General Public License v3.0
3 stars 0 forks source link

Make use of `using` declarations in our vendored `tidy` #1187

Closed dhess closed 2 months ago

dhess commented 2 months ago

Upstream tidy uses the TypeScript “disposable” pattern by copy-pasting some boilerplate-y code: https://github.com/zxch3n/tidy/blob/master/src/dispose.ts

If I understand correctly, this pattern is built into (in preview form) recent versions of TypeScript: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html. It can be enabled as follows:

{
    "compilerOptions": {
        "target": "es2022",
        "lib": ["es2022", "esnext.disposable", "dom"]
    }
}

Assuming we implement #1186, we should look into enabling this and refactoring the vendored code to use it.

dhess commented 2 months ago

I don't think we can easily use using, but we can use the built-in Disposable interface.