Skip to content

Updates Emscripten types with new MODULARIZE API#44590

Merged
sandersn merged 2 commits intoDefinitelyTyped:masterfrom
lourd:emscripten-factory-types
May 15, 2020
Merged

Updates Emscripten types with new MODULARIZE API#44590
sandersn merged 2 commits intoDefinitelyTyped:masterfrom
lourd:emscripten-factory-types

Conversation

@lourd
Copy link
Copy Markdown
Contributor

@lourd lourd commented May 9, 2020

Don't merge until the new release of Emscripten has been cut


This corresponds with the changes to Emscripten in emscripten-core/emscripten#10697,
creating a type for the new Promise-based API of the factory function
generated when using MODULARIZE.

Removes the obsolete then method from EmscriptenModule and separates
the type for the factory function generated when using the MODULARIZE
build option from the rest of the EmscriptenModule interface. This
will make it easier to extend the interface.

Also removes the global Module variable declaration as this is not
applicable for every application. This was not ideal as it left a very
generic variable name in the global scope for any application that used
Emscripten, regardless of whether there was actually a global variable.
This now leaves it up to the user to declare their module instance as
appropriate for them.

Fixes the reference in sql.js, using the EmscriptenModule interface
directly.


  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).
  • Provide a URL to documentation or source code which provides context for the suggested changes: Implements Promise-based API for modularized builds emscripten-core/emscripten#10697
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
  • Include tests for your changes

Louis DeScioli added 2 commits May 8, 2020 20:14
This corresponds with the changes to Emscripten in emscripten-core/emscripten#10697,
creating a type for the new Promise-based API of the factory function
generated when using `MODULARIZE`.

Removes the obsolete `then` method from EmscriptenModule and separates
the type for the factory function generated when using the `MODULARIZE`
build option from the rest of the `EmscriptenModule` interface. This
will make it easier to extend the interface.

Also removes the global `Module` variable declaration as this is not
applicable for every application. This was not ideal as it left a very
generic variable name in the global scope for any application that used
Emscripten, regardless of whether there was actually a global variable.
This now leaves it up to the user to declare their module instance as
appropriate for them.

Fixes the reference in sql.js, using the EmscriptenModule interface
directly.
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented May 9, 2020

@lourd Thank you for submitting this PR!

Code Reviews

Because this PR edits multiple packages, it can be merged once it's reviewed by a DT maintainer.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ❌ Only a DT maintainer can merge changes without tests

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 44590,
  "author": "lourd",
  "owners": [
    "zakki",
    "periklis",
    "kbumsik",
    "Hozuki",
    "ffflorian"
  ],
  "dangerLevel": "MultiplePackagesEdited",
  "headCommitAbbrOid": "cdce35b",
  "headCommitOid": "cdce35b4d471b29711ba7fee186c95d52c18cea4",
  "mergeIsRequested": false,
  "stalenessInDays": 6,
  "lastCommitDate": "2020-05-09T00:21:06.000Z",
  "lastCommentDate": "2020-05-15T17:21:38.000Z",
  "reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44590/files",
  "hasMergeConflict": false,
  "authorIsOwner": false,
  "isFirstContribution": false,
  "popularityLevel": "Well-liked by everyone",
  "anyPackageIsNew": false,
  "packages": [
    "emscripten",
    "sql.js"
  ],
  "files": [
    {
      "filePath": "types/emscripten/emscripten-tests.ts",
      "kind": "test",
      "package": "emscripten"
    },
    {
      "filePath": "types/emscripten/index.d.ts",
      "kind": "definition",
      "package": "emscripten"
    },
    {
      "filePath": "types/sql.js/module.d.ts",
      "kind": "definition",
      "package": "sql.js"
    }
  ],
  "hasDismissedReview": false,
  "travisResult": "pass",
  "lastReviewDate": "2020-05-09T01:23:28.000Z",
  "reviewersWithStaleReviews": [],
  "approvalFlags": 2,
  "isChangesRequested": false
}

@typescript-bot
Copy link
Copy Markdown
Contributor

🔔 @zakki @periklis @kbumsik @hozuki @ffflorian - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot
Copy link
Copy Markdown
Contributor

🔔 @zakki @periklis @kbumsik @hozuki @ffflorian - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot
Copy link
Copy Markdown
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

emscripten/v*

Comparison details for emscripten/* 📊
master #44590 diff
Batch compilation
Memory usage (MiB) 84.2 73.6 -12.6%
Type count 10378 10486 +1%
Assignability cache size 34516 34521 0%
Language service
Samples taken 268 297 +11%
Identifiers in tests 268 297 +11%
getCompletionsAtPosition
    Mean duration (ms) 297.7 299.4 +0.6%
    Mean CV 12.0% 11.7%
    Worst duration (ms) 366.6 379.0 +3.4%
    Worst identifier strPtr createModule
getQuickInfoAtPosition
    Mean duration (ms) 285.5 289.0 +1.2%
    Mean CV 10.7% 10.6% -1.4%
    Worst duration (ms) 354.3 361.8 +2.1%
    Worst identifier _free unlink

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

sql.js/v*

Comparison details for sql.js/* 📊
master #44590 diff
Batch compilation
Memory usage (MiB) 103.3 108.5 +5.0%
Type count 15539 15538 0%
Assignability cache size 33895 33895 0%
Language service
Samples taken 104 104 0%
Identifiers in tests 104 104 0%
getCompletionsAtPosition
    Mean duration (ms) 531.4 532.5 +0.2%
    Mean CV 10.4% 10.2%
    Worst duration (ms) 690.8 666.8 -3.5%
    Worst identifier each selectRecordsStatement
getQuickInfoAtPosition
    Mean duration (ms) 528.5 533.8 +1.0%
    Mean CV 9.7% 10.3% +5.6%
    Worst duration (ms) 636.1 633.5 -0.4%
    Worst identifier b db

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label May 9, 2020
Copy link
Copy Markdown
Contributor

@kbumsik kbumsik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving @types/emscripten!
I glad to see then() is finally removed. While reading emscripten-core/emscripten#10697 I am surprised by the amount of effort just to make it a real promise. That's much more than I'd imagine. Thanks so much!

I also like the idea of removing Module in favor of EmscriptenModuleFactory. LGTM.

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label May 9, 2020
Copy link
Copy Markdown
Contributor

@hozuki hozuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sql.js part has the same type reference as before. As long as emscripten's definitions are correct, sql.js' def works too.

@sandersn
Copy link
Copy Markdown
Contributor

@lourd emscripten-core/emscripten#10697 is merged. Is this PR ready to go? If not, which version is it waiting on, and where can I go to check whether that version has been released?

@kbumsik
Copy link
Copy Markdown
Contributor

kbumsik commented May 13, 2020

@sandersn The PR is merged but it is not released yet. Specifically it is waiting for 1.39.16 and the current release is 1.39.15. You can check it here: https://github.com/emscripten-core/emscripten/releases
Emscripten releases every 1 or 2 weeks so it will be soon I guess. I will leave a comment when it is released.

@lourd
Copy link
Copy Markdown
Contributor Author

lourd commented May 15, 2020

1.39.16 was just released this morning, this should be good to go!

@sandersn sandersn merged commit 32b5dfe into DefinitelyTyped:master May 15, 2020
@typescript-bot
Copy link
Copy Markdown
Contributor

I just published @types/[email protected] to npm.

@kbumsik
Copy link
Copy Markdown
Contributor

kbumsik commented May 24, 2020

Just mentioning emscripten-core/emscripten#10271 to keep track of it.

jjballano-qatium pushed a commit to jjballano-qatium/DefinitelyTyped that referenced this pull request Jun 16, 2020
* Updates Emscripten types with new `MODULARIZE` API

This corresponds with the changes to Emscripten in emscripten-core/emscripten#10697,
creating a type for the new Promise-based API of the factory function
generated when using `MODULARIZE`.

Removes the obsolete `then` method from EmscriptenModule and separates
the type for the factory function generated when using the `MODULARIZE`
build option from the rest of the `EmscriptenModule` interface. This
will make it easier to extend the interface.

Also removes the global `Module` variable declaration as this is not
applicable for every application. This was not ideal as it left a very
generic variable name in the global scope for any application that used
Emscripten, regardless of whether there was actually a global variable.
This now leaves it up to the user to declare their module instance as
appropriate for them.

Fixes the reference in sql.js, using the EmscriptenModule interface
directly.

* Runs prettier on the emscripten types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Owner Approved A listed owner of this package signed off on the pull request. Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants