+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

fix(js-api): fix the JS API tests #3884

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions npm/js-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,11 @@ export interface PrintDiagnosticsOptions {
verbose?: boolean;
}

// If `FinalizationRegistry` is supported, use it as a safety measure to ensure
// Workspace instances get deallocated in case `shutdown` isn't called
let registry: FinalizationRegistry<Workspace> | null = null;
if (typeof FinalizationRegistry === "function") {
registry = new FinalizationRegistry((workspace) => {
workspace.free();
});
}

export class Rome {
private constructor(
private readonly module: WasmModule,
private readonly workspace: Workspace,
) {
registry?.register(this, workspace);
}
) {}

/**
* It creates a new instance of the class {Rome}.
Expand All @@ -122,7 +111,6 @@ export class Rome {
* unusable as calling any method on it will fail
*/
public shutdown() {
registry?.unregister(this);
this.workspace.free();
}

Expand Down
11 changes: 2 additions & 9 deletions npm/js-api/tests/__snapshots__/lintContent.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ exports[`Rome WebAssembly lintContent > should lint content > lint diagnostics 1
},
{
"Frame": {
"path": {
"File": {
"FileId": 0,
},
},
"path": null,
"source_code": null,
"span": [
6,
Expand Down Expand Up @@ -125,10 +121,7 @@ exports[`Rome WebAssembly lintContent > should lint content > lint diagnostics 1
"location": {
"path": {
"File": {
"PathAndId": {
"file_id": 0,
"path": "example.js",
},
"Path": "example.js",
},
},
"source_code": null,
Expand Down
1 change: 0 additions & 1 deletion npm/js-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["ES2020", "ESNext.WeakRef"],
"module": "commonjs", /* Specify what module code is generated. */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declarationMap": true, /* Create sourcemaps for d.ts files. */
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载