Repository: sandersn/downlevel-dts (js)

Issue:
Downlevel private fields
```ts
export declare class C {
  #private: string;
}
```

Proposed emit

```ts
declare const private: unique symbol;

export declare class C {
  private [private]: string
}
```

Pull request description:
Private fields
Fixes #14 in a simple way. 

Patch:
diff --git a/index.js b/index.js
index 72d49cf..ffedd05 100644
--- a/index.js
+++ b/index.js
@@ -82,6 +82,18 @@ function doTransform(checker, k) {
           /*initialiser*/ undefined
         );
       }
+    } else if (ts.isPropertyDeclaration(n) && ts.isPrivateIdentifier(n.name) && n.name.escapedText === "#private") {
+      // #private => private "#private"
+      const modifiers = ts.createModifiersFromModifierFlags(ts.ModifierFlags.Private);
+      const parentName = n.parent.name ? n.parent.name.escapedText : "(anonymous)";
+      return ts.createProperty(
+        n.decorators,
+        modifiers,
+        ts.createStringLiteral(parentName + ".#private"),
+        /*?! token*/ undefined,
+        /*type*/ undefined,
+        /*initialiser*/ undefined
+      );
     } else if (
       ts.isExportDeclaration(n) &&
       n.exportClause &&


Test patch:
diff --git a/baselines/ts3.4/test.d.ts b/baselines/ts3.4/test.d.ts
index ffc1bcc..afbd073 100644
--- a/baselines/ts3.4/test.d.ts
+++ b/baselines/ts3.4/test.d.ts
@@ -21,3 +21,9 @@ export interface E {
     b: number;
 }
 export type F = Pick<E, Exclude<keyof E, 'a'>>;
+export class G {
+    private "G.#private";
+}
+export class H extends G {
+    private "H.#private";
+}
diff --git a/index.test.js b/index.test.js
index 016386d..f3c7cf4 100644
--- a/index.test.js
+++ b/index.test.js
@@ -19,11 +19,11 @@ suite("main", {
       sh.rm("-r", "test/ts3.4");
     }
     main("test", "test/ts3.4");
-    expect(fs.readFileSync("baselines/ts3.4/test.d.ts", "utf8")).toEqual(
-      fs.readFileSync("test/ts3.4/test.d.ts", "utf8")
+    expect(fs.readFileSync("test/ts3.4/test.d.ts", "utf8")).toEqual(
+      fs.readFileSync("baselines/ts3.4/test.d.ts", "utf8")
     );
-    expect(fs.readFileSync("baselines/ts3.4/src/test.d.ts", "utf8")).toEqual(
-      fs.readFileSync("test/ts3.4/src/test.d.ts", "utf8")
+    expect(fs.readFileSync("test/ts3.4/src/test.d.ts", "utf8")).toEqual(
+      fs.readFileSync("baselines/ts3.4/src/test.d.ts", "utf8")
     );
   }
 });
diff --git a/test/test.d.ts b/test/test.d.ts
index 5dbe13e..a351f6c 100644
--- a/test/test.d.ts
+++ b/test/test.d.ts
@@ -25,3 +25,10 @@ export interface E {
 }
 
 export type F = Omit<E, 'a'>;
+
+export class G {
+    #private
+}
+export class H extends G {
+    #private
+}