-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uprade to comlink v4 #10149
Uprade to comlink v4 #10149
Conversation
The test failure is a bug in Babel 😮 "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ExtLanguageFeatures = void 0;
var _comlink = require("@sourcegraph/comlink");
var _util = require("../../util");
var _common = require("./common");
var _types = require("./types");
/* eslint-disable no-sync */
/** @internal */
class ExtLanguageFeatures {
constructor(proxy, documents) {
this.proxy = _comlink.proxy; // should be proxy, not _comlink.proxy!
this.documents = documents;
} |
0852348
to
eff60c3
Compare
TypeScript property initializers and named imports compiled to CommonJS name-conflict and result in the wrong value being assigned.
f6cc0be
to
d0273f2
Compare
Codecov Report
@@ Coverage Diff @@
## master #10149 +/- ##
=======================================
Coverage 42.77% 42.77%
=======================================
Files 1348 1348
Lines 74137 74136 -1
Branches 6651 6659 +8
=======================================
+ Hits 31711 31712 +1
+ Misses 39570 39568 -2
Partials 2856 2856
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I much prefer the local/remote naming 👍
|
||
export const isEndpointPair = (value: unknown): value is EndpointPair => | ||
isObject(value) && | ||
hasProperty('proxy')(value) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to use hasProperty
a lot more, what would you think about having curriedHasProperty()
(maybe there's a better name) and hasProperty()
?
filter(curriedHasProperty('postMessage'))
// or
const isFoo = (bar: unknown) => hasProperty('foo', bar)
The hasProperty()()
syntax is a bit alien/odd and I'd like to avoid odd patterns from proliferating in our codebase as much as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I thought about this too, and I had the same initial reaction. But I thought it would be weird/annoying to have the "curried" prefix and dual versions for every type guard too. One thought I had was that this may be one of these things that feel weird at first but you get used to it quickly.
Another thing I thought about was having a function to compose type guards, like all(...typeGuards)(value)
. That would avoid having to repeat the call with value
for every type guard. I haven't found out how to type that yet though.
Ideally TypeScript would also just implement microsoft/TypeScript#21732 (which will happen eventually, given it has the label Committed
), and then we can just use the in
operator in non-functional contexts, while hasProperty()
continues to serve the curried use case (and in that scenario, it would be nice if it doesn't need the "curried" prefix).
I propose we just leave it as-is for a bit and see where it goes (maybe improve with an all()
helper, and/or maybe TS will ship in
support sometime this year).
* Uprade to comlink v4 (fork) * Workaround Babel bug TypeScript property initializers and named imports compiled to CommonJS name-conflict and result in the wrong value being assigned. * Use new string channel From https://github.com/GoogleChromeLabs/comlink/blob/string-channel/src/string-channel.experimental.ts * Fix browser extension decoration tests
Closes #3989.
There were a bunch or renames, and StringMessageChannelAdapter is no longer bundled with comlink. There is a new experimental string channel support, that is less leaky.
Corresponding upstream comlink PR to fix types: GoogleChromeLabs/comlink#451
Tested manually in the webapp and browser extension.