PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: alangpierce/sucrase (ts)

Issue:
Constructor return type annotations produce invalid JS syntax
Source:
```js
class Foo {
  constructor(): Foo {
    return this;
  }
}
```

Transformed (actual):
```js
class Foo {
  constructor():  {
    return this;
  }
}
```

Transformed (expected):
```js
class Foo {
  constructor()  {
    return this;
  }
}
```

Reproductions:
- TS: https://sucrase.io/#transforms=typescript&code=class%20Foo%20%7B%0A%20%20constructor()%3A%20Foo%20%7B%0A%20%20%20%20return%20this%3B%0A%20%20%7D%0A%7D
- Flow: https://sucrase.io/#transforms=flow&code=class%20Foo%20%7B%0A%20%20constructor()%3A%20Foo%20%7B%0A%20%20%20%20return%20this%3B%0A%20%20%7D%0A%7D

Pull request:
Remove constructor return type annotations
Fixes #795

This syntax isn't actually valid, but it's easy enough to product working JS to avoid blocking the developer, so this implements that.

Patch:
diff --git a/src/util/getClassInfo.ts b/src/util/getClassInfo.ts
index 80aee82..33f6081 100644
--- a/src/util/getClassInfo.ts
+++ b/src/util/getClassInfo.ts
@@ -278,6 +278,11 @@ function processConstructor(tokens: TokenProcessor): {
   }
   // )
   tokens.nextToken();
+  // Constructor type annotations are invalid, but skip them anyway since
+  // they're easy to skip.
+  while (tokens.currentToken().isType) {
+    tokens.nextToken();
+  }
   let constructorInsertPos = tokens.currentIndex();
 
   // Advance through body looking for a super call.


Test patch:
diff --git a/test/typescript-test.ts b/test/typescript-test.ts
index b1865eb..8c7447c 100644
--- a/test/typescript-test.ts
+++ b/test/typescript-test.ts
@@ -3714,4 +3714,26 @@ describe("typescript transform", () => {
       {transforms: ["typescript"]},
     );
   });
+
+  it("removes return type annotations from constructors", () => {
+    // Constructor return types aren't valid, but we return them anyway since
+    // it's easy and improves the DX when people make the mistake.
+    assertResult(
+      `
+      class A {
+        constructor(): A {
+          return this;
+        }
+      }
+    `,
+      `
+      class A {
+        constructor() {
+          return this;
+        }
+      }
+    `,
+      {transforms: ["typescript"]},
+    );
+  });
 });
Repository: brightcove/hot-shots (js)

Issue:
Keep buffers from mocked calls for test inspection.
We're trying to write tests for our stats client which wraps hotshots. There are some instances where we can't supply a callback to each 'count' or 'timing' call. In order to test that our stats are emitting properly, we're having to use https://github.com/mattrobenolt/node-mock-udp to ensure that we're sending the right data.

It would be nice if hot-shots would record the outgoing buffers when `{mock: true}` is passed.

Pull request:
Add support for recording buffers in mock mode
Fixes #77 

Patch:
diff --git a/lib/statsd.js b/lib/statsd.js
index b898cb7..2841b4e 100644
--- a/lib/statsd.js
+++ b/lib/statsd.js
@@ -64,6 +64,11 @@ var Client = function (host, port, prefix, suffix, globalize, cacheDns, mock,
   this.bufferHolder = options.isChild ? options.bufferHolder : { buffer: "" };
   this.errorHandler = options.errorHandler;
 
+  // If we're mocking the client, create a buffer to record the outgoing calls.
+  if (this.mock) {
+    this.mockBuffer = [];
+  }
+
   // We only want a single flush event per parent and all its child clients
   if(!options.isChild && this.maxBufferSize > 0) {
     this.intervalHandle = setInterval(this.onBufferFlushInterval.bind(this), this.bufferFlushInterval);
@@ -247,6 +252,7 @@ Client.prototype._send = function (message, callback) {
     }
   }
   else {
+    this.mockBuffer.push(message);
     if(typeof callback === 'function'){
       callback(null, 0);
     }


Test patch:
diff --git a/test/test_statsd.js b/test/test_statsd.js
index d325342..5733bf3 100644
--- a/test/test_statsd.js
+++ b/test/test_statsd.js
@@ -740,7 +740,7 @@ function doTests(StatsD) {
     });
 
   });
-  
+
   describe('#distribution', function(){
     it('should send proper distribution format without prefix, suffix, sampling and callback', function(finished){
       udpTest(function(message, server){
@@ -1563,6 +1563,15 @@ function doTests(StatsD) {
       statsd.send('test title');
     });
 
+    it('should record buffers when mocked', function (finished) {
+      var statsd = new StatsD({
+        mock: true
+      });
+      statsd.send('test', {}, function() {
+        assert.deepEqual(statsd.mockBuffer, ['test']);
+        finished();
+      });
+    });
   });
 
   describe('#sendMessage', function() {