Supporting 'this' type

Background
We've had a few requests to support this typing (like #229).  This proposal addresses the use cases for a function 'this' type, a class 'this' type, and a corresponding feature for interfaces.
Motivating Examples
Extension (lightweight mixin)
interface Model {
  extend<T>(t: T): <type of containing interface> & T;
}

interface NamedModel extends Model {
  name: string;
}

declare function createNameModel(): NamedModel;

var modelWithNameAndAge = createNamedModel().extend({
  age: 30
});
modelWithNameAndAge.name; //valid
modelWithNameAndAge.age; // valid

Safe instantiation
function f() {
  this.x = 3;
}
var g = new f(); // gives type an easy way to check f's body or specify instantiated type

Safe method invocation
function f() {
  this.x = 3;
}
var obj = {y: "bar", f: f};
obj.f(); // can’t easily error

Well-typed fluent APIs (also useful for cloning)
class Parent {
  setBase(property, value): <whatever the child class is> {
    this._secretSet(property, value);
    return this;
  }
}

class Child extends Parent {
  name:string;
}

var c = new Child();
console.log(c.setBase("foo", 1).setBase("bar", 2").name);  //valid

Design
To support the motivating examples, we introduce a 'this' type.  The 'this' type should follow the intuition of the developer.  When used with classes, 'this' type refers to the type of the class it finds itself in.  With functions, 'this' allows you to further document how the function will be used as a constructor and in what context it can be invoked while in an object.
Classes and 'this'
A class that uses a 'this' is referring to the containing named class.  In the simplest example:
class C {
  myThis(): this { return this; }
}
var c = new C();
var d = c.myThis();

We trivially map the 'this' type in the invocation of myThis() to the C type, giving 'd' type C.
The type of 'this' will follow with subclasses.  A subclass sees any 'this' in the type of its base class as its own type.  This allows more a fluent API, as in this example:
class C {
  myThis(): this { return this; }
}
class D extends C {
  name: string;
}
var D = new D();
d.myThis().name = "Joe"; //valid

For this to work correctly, only 'this' or something that resolves to 'this' can be used.  Something which looks like it should work correctly, but can't work safely is this example:
class C {
  newInstance(): this {
    return new C(); // error, 'this' only works with this expressions
  }
}

Functions and 'this'
Functions gain the ability to talk about the shape of the 'this' pointer that is visible in the function body.  The design here leverages the type variables of the function to describe what the shape of 'this' has:
function f<this extends {x:number}>() {
  this.x = 3;
}

This is fairly readable, and we could use syntax coloring/tooling to help signify that the 'this' here is a special type variable that is implied by all functions.
Once the type of 'this' is described for functions, we can check the inside of the function body, where this is used:
function f<this extends {x:number}>() {
  this.x = 3;
  this.y = 6; //error: y is not available on this
}

We can also check invocation sites:
var o = {myMethod: f, y: "bob"};
o.myMethod(); //error: o does not match the shape of 'this' for 'myMethod'

We may even want to error on the assignment when object is first created instead of the invocation site.
Interfaces and 'this'
Similarly to classes, interfaces currently lack the the ability for a type to refer to itself.  While an interfaces can refer to itself by name, this limits the ability of interfaces that extend the original interface.  Here, we introduce 'this' as a way for interfaces to do this:
interface Model {
  clone(): this;
}

interface NamedModel extends Model {
  name: string;
}

var t:NamedModel;
t.clone().name; // valid

For this to work, 'this' refers to the containing named type.  This helps eliminate ambiguities like this:
interface I {
  obj: { myself: this; name: string };
}

In this example, 'this' refers to I rather than the object literal type.  It's trivial to refactor the object literal type out of the class so that you can describe a 'this' that instead binds to the object literal itself.
Motivating examples (Redux)
In this section, we re-write the motivating examples using the proposed functionality.
Extension (lightweight mixin)
interface Model {
  extend<T>(t: T): this & T;
}

interface NamedModel extends Model {
  name: string;
}

declare function createNameModel(): NamedModel;

var modelWithNameAndAge = createNamedModel().extend({
  age: 30
});
modelWithNameAndAge.name; //valid
modelWithNameAndAge.age; // valid

Safe instantiation
function f<this extends {x:number}>() {
  this.x = 3;
}
var g = new f(); // gives type an easy way to check f's body or specify instantiated type

Safe method invocation
function f<this extends {x: number}>() {
  this.x = 3;
}
var obj = {y: "bar", f: f};
obj.f(); // error: f can not be invoked on obj, missing {x: number}

Well-typed fluent APIs (also useful for cloning)
class Parent {
  setBase(property, value): this {
    this._secretSet(property, value);
    return this;
  }
}

class Child {
  name:string;
}

var c = new Child();
console.log(c.setBase("foo", 1).setBase("bar", 2").name);  //valid

Should methods now all implicitly gain a this type variable? This would prevent users from shooting themselves in the foot. For example:
class C {
    prop: number;
    method() {
        return this.x;
    }
}

let c = new C();
let removedMethodHandle = c.method;
console.log(removedMethodHandle());

@DanielRosenwasser possibly?  Though I suspect that won't give you what you need.  If the 'this' type shows up in the type of c.method, if you pass it to a callback that forgets the 'this' piece of the type, you won't catch the error.

'this' is a good idea. Also it could be applied to the 'call', 'bind' and 'apply' scenarios.
For Example:
class A {
    name: string;

    setName<this extends { name: string;}>(val:string) {
        this.name = val;
    }
}

class B {
    somethingElse: string;
 }

class C { name: string; }

var setName = new A().setName;
var b = new b();
var c = new C();
setName.apply(b, ["hello"]); //error
setName.call(b, "hello"); //error
setName.bind(b)("hello"); //error

setName.apply(c, ["hello"]); //ok
setName.call(c, "hello"); //ok
setName.bind(c)("hello"); //ok

:+1:  for the proposal
For the interface and class part, it seems this type overlaps a lot with F-bounded polymorphism. Can this type cover the latter?

Some questions that come to mind...
(1) Your proposal doesn't specifically say, but I assume within a class this would denote a type that behaves like a subtype of the containing class (effectively like a type parameter with the current class as a constraint). That means we'd break the following code:
class C {
    foo() {
        var x = this;
        x = new C();
    }
}

(2) The proposal doesn't specify what the type of a method in a class is. For example:
class C {
    f() { }
}
var c = new C();
var f = c.f;  // Ideally of type <this extends C>() => void
f();          // Should be an error

the type of f currently is () => void, but I assume it would now be <this extends C>() => void. That would ensure f can't accidentally be called without a proper this.
(3) What are the type compatibility rules for function types with this type arguments? For example:
var c = new C();
var f: () => void = c.f;  // Is this allowed?

If we treat this as a type parameter, the above assignment would be allowed because we erase type parameters when checking assignment compatibility of signatures. That might in fact be the right thing to do because anything stricter would break a lot of existing code. But it is something we need to consider.

@ahejlsberg, my comment brings up (2). From what I understand, @jonathandturner responded that because of your point in (3), we lose the benefit resulting from (2) because of the callback case.
We could instead always take this constraints into account, and say that if an instance method never accesses this, it does not receive a this constraint. This way, we'd only break code in cases where a this handle was actually used, though, I could see it as slightly awkward to enforce this consistency.

Couldn't the above use case be covered by this?
interface Foo {
  bar(this: Foo & Bar): void;
}

interface Bar {
  bar(this: Foo | Bar): void
}

That, I believe, fits closer to the emerging syntax consensus in #229.

@impinball could you clarify which use case you're referring to?

Sorry...I meant the this in function types in the main proposal. It wasn't specifically about your comment...probably should have mentioned @jonathandturner.
Also, as for that mixin model, there's already half a dozen mixin proposals out there, but this specific version proposed in the main bug is probably not the best way to go (feels incomplete).

@ahejlsberg - yeah, good to call out (1).  Though I allude to it in the proposal by talking about assignment compat with 'this', I think the way you spell it out works better and gives a better intuition.
@DanielRosenwasser - We should explore implied 'this' constraint more, and try it out on some real world code to see what impact it might have.
@impinball - agreed. This isn't intended to be used as a complete mixin solution, rather a way of modeling extension like how some libraries (like Ember) do extensibility.  For a full mixin story, you'd want the type-checking part (including something like intersection types) combined with a code generation piece.

:+1: though concerned about what 'this' refers to for the mixin/composition story. Are the mixed in methods included or only the single inheritance?

@jbondc - do you have an example you think would cause problems?

With a trait model, composition is where declared:
enum D {
  d
}
class B { b() {} }
class C { c() {} }
class A {
   import B, C, D; // composed here at compile time
   me(): this { return this } // includes me(), b(), c(), d
}
enum D {
  e
}

With a ~mixin model, it's unclear:
enum D {
  d
}
class A mixin(B, C, D) {
   me(): this { return this } // includes me(), b(), c(), d, e?
}
// any declaration merging, is this part of A?
enum D {
  e
}

Do later declarations get included?

To verbalize my concern, if people start using the 'mixin model' and expect 'this' to include later declarations, that conflicts with the trait model which to my understanding would be how things get merged in ES${x}.

I'm not sure exactly what your semantics are here, since this isn't valid JS/TS.
A related example in valid JS should show it a bit better:
class A extends mixin(B, C, D) {
   me(): this { return this } // includes me(), b(), c(), d, e?
}

So yeah, from the original example in the writeup a subclass would have a 'this' type that reflects the shape of the class.  Unfortunately, I don't think there's enough descriptive power in the type system to cover the mixin forms.

(not to say there couldn't be in the future)

Yep forgot the 'ClassHeritage' thing, meant the extends mixin(B, C, D)

For the previous 'trait syntax', I meant something like this:
http://wiki.ecmascript.org/doku.php?id=strawman:trait_composition_for_classes

This also allows classical inheritance to be modeled:star::star::star: correctly :star::star::star:.
It's not just a mixin problem.
(Yes, that amount of emphasis is necessary. I know of no other type system that fails at this, not even Java, C++, or C#. To me, the current behavior exposes a broken OO type system, and really is a bug in of itself.)
It's required to type libraries with deep object hierarchies. One such example, Lazy.js, cannot be typed without full type inheritance of delegated methods. It uses inheritance very frequently, with a very deep inheritance hierarchy. Its API uses a relatively deep hierarchy (although I also still need a way to override the return type of an inherited method for a couple specific cases in its API, namely the async equivalents of each). Lodash has a similar problem. Another example is the following code:
class A {
  foo(): this { return this }
}

class B extends A {
  bar(): this { return this }
}

new B().foo().bar()

If you change the above to this, it will fail to compile. That is surprising behavior for anyone used to most other static OO type systems.
class A {
  foo(): A { return this }
}

class B extends A {
  bar(): B { return this }
}

new B().foo().bar() // Property 'bar' does not exist on type 'A'.

This is kinda required for a few too many things.

I know of no other type system that fails at this, not even Java, C++, or C#
...
That is surprising behavior for anyone used to most other static OO type systems.

I'm not sure what you're talking about, as far as I understand, none of those languages has self-typing.

If you change the above to this, it will fail to compile.

Yes, because this is currently under proposal.

The equivalent doesn't fail with Java 6 or later, correct? It's more about
the B still being a B, after being returned from an A.
On Sat, Jul 18, 2015, 14:27 Daniel Rosenwasser<EMAIL_ADDRESS>wrote:

I know of no other type system that fails at this, not even Java, C++, or
C#
...
That is surprising behavior for anyone used to most other static OO type
systems.
I'm not sure what you're talking about, as far as I understand, none of
those languages has self-typing.
If you change the above to this, it will fail to compile.
Yes, because this is currently under proposal.
—
Reply to this email directly or view it on GitHub
https://github.com/Microsoft/TypeScript/issues/3694#issuecomment-122575250
.

The equivalent doesn't fail with Java 6 or later, correct?

No, it fails, and it even fails in Java 8.

class A {
  foo(): this { return this }
}

class B extends A {
  bar(): this { return this }
}

new B().foo().bar()

It seems to me that this should always fail to compile. Foo returns this, which is A. Why should parent class A know anything about B's method bar?

It seems to me that this should always fail to compile. Foo returns this, which is A. Why should parent class A know anything about B's method bar?

While it is difficult to figure out at compile time, it is what is actually happening at runtime.  Because this is simply a reference to the instance, means at runtime, the last statement is valid.  So the argument is why couldn't TypeScript support this.  This is valid ES6:
class A {
    foo() { return this }
}

class B extends A {
    bar() { return this }
}

new B().foo().bar();

Okay. I'll take back most of my claims about other languages. I didn't realize that they also had the same problem. I'll take another approach: could TypeScript finally get this right? It's runtime behavior that should also be possible to infer statically, without a lot of trouble.

@MgSam yup, it's what @kitsonk says.  There's a difference here between 'this' type and returning the class type.  Your example without the 'this' type would throw the error:
class A {
  foo(): A { return this }
}

class B extends A {
  bar(): B { return this }
}

new B().foo().bar()  // error Property 'bar' does not exist on type 'A'.

The 'this' typing is closer to what's happening at runtime, which is that B's instance is what is available after the new call.

I might point out that supporting the "this" type will be super helpful when using the bind operator.
It even looks like there are plans to support the bind operator in TypeScript, judging by the looks of 8521632d1c2ee34939de8dbde6915c6d259e0c1d.

+1 +1 +1 I just came across this issue working with decorators, and was trying to do stuff like this to solve the problem:
function bar(): void {
  declare this: Foo;
}

But after reading the proposals, now I like this:
function bar<this: Foo>(): void {}

over this:
function bar(this: Foo): void;

or this:
function bar<this extends Foo>(): void {}

@MgSam Why should that example fail to compile? It's a perfectly valid use of chaining. Here's something more concrete:
/// <reference path="../typings/angularjs/angular.d.ts" />

interface CachingModule extends angular.IModule {
  cache(object: Object): CachingModule;
}

var m:CachingModule;

m.cache({}).constant("foo", "bar"); //valid, but
m.constant("foo", "bar").cache({}); //error

class Example {
  func(): this;
  static func(): this;
}

Should the static function return type be the constructor type typeof Example? or the instance type?
If the static this is alternatively supported say, through, typeof this wouldn't that be confusing?
If the this type is supported, how will a natural extension like this.func handle this ambiguity?
If the class or function is merged with a namespace, or an ambient class is merged with an interface, what will this mean on those scenarios?
Will the this type of a class instance and interface be also accessible from the outside? what syntax is planned for that?

Here's my current solution for this problem, although I don't like it (I needed this for a lot of interface definitions):
interface Foo<T extends Foo<any>> {
  // ...
}

This idiom is very common in other languages with generics/templates, which also suffer from this same problem.
// Java
class Foo<T extends Foo> {
  // ...
}

@rotemdan

It returns the type of the actual instance, much like ES6's new.target, but statically determined. It's resolved on the caller's side, not the callee's side.
That would refer to the this instance the function is called with, usually the class itself. It's still resolved on the callee's side.
Types and values are parsed in different contexts, and are kept in independent namespaces. For this reason, you can still have a variable named string.
See 1.
Highly doubt it. The function itself has no clue what this represents in it unless it's constrained (methods' this types are already implicitly constrained to their containing class) or explicitly typed.

@impinball
My questions are mostly related to ambiguities in the semantics, not necessarily the syntax. This includes ambiguities between references to run-time entities like namespaces and pure types like interfaces, static and instance member types, etc. Even if the syntax may not be ambiguous (at least from the point of view the compiler), the semantics could be, from the perspective of the developer.
Now:

The feature is for type positions, E.g. let x: this, which in TypeScript is purely a compile-time construct, there is no concept or "callee" or "caller", any piece of metadata that is available within any scope, including the this type can be unambiguously made available in outside the declaration class/interface declaration.
The question was about the semantics of this when referenced from a static position in the declaration. However, there is also a purely syntactic problem here in the case of a generic class:

class Example<T> {
  x: this;
  static y: this; // This is impossible
}

It is impossible to resolve the type of the expression Example.y because the type parameter is only valid for instances, E.g.. Example<number>.y is not valid.
3. The question was about semantics from the point of view of a human, not a mechanical difficulty of the compiler to disambiguate between different statements.
4. The question was about semantics.
5. Like 1. This is just compile time metadata, it can unambiguously be made available at any point and position of the code.

Okay, to revisit your initial questions:

Yes. The type should be typeof Example.
I see no reason why it shouldn't be identical to typeof Example.
That's the least surprising outcome.
For one, I don't think it should be supported in the first place. Two,
even if it is, that's not a straightforward thing for even a human to
figure out. There's also the problem that the implementation could provide
a more permissive type than the interface itself. That would bring
nightmares for bug catching, as the type can't be determined by merely
looking at it. In some cases, you would have to look across files to figure
out all the pieces (they would be pieces).
It would represent the context it's defined in. If it's in a class, it
refers to the type of the instance. If it's in an interface, it refers to
an instance of that interface. If it's the return type of a function, it
deals with the this inside the function.
Probably not. It's defined per-function. And I doubt there's much of a
use case for getting that context outside the function.

Sorry for not quite understanding your question. Is this better?
On Thu, Sep 17, 2015, 04:00 Rotem Dan<EMAIL_ADDRESS>wrote:

@impinball https://github.com/impinball
My questions are mostly related to ambiguities in the semantics, not
necessarily the syntax. This includes ambiguities between references to
run-time entities like namespaces and pure types like interfaces, static
and instance member types, etc. Even if the syntax may not be ambiguous (at
least from the point of view the compiler), the semantics could be, from
the perspective of the developer.
Now:

The feature is for type positions, E.g. let x: this, which in
TypeScript is purely a compile-time construct, there is no concept or
"callee" or "caller", any piece of metadata that is available within any
scope, including the this type can be unambiguously made available in
outside the declaration class/interface declaration.
The question was about the semantics of this when referenced from a
static position in the declaration. However, there is also a purely
syntactic problem here in the case of a generic class:

class Example {
x: this;
static y: this; // This is impossible
}
It is impossible to resolve the type of the expression Example.y because
the type parameter is only valid for instances, E.g.. Example.y
is not valid.
3. The question was about semantics from the point of view of a human, not
a mechanical difficulty of the compiler to disambiguate between different
statements.
4. The question was about semantics.
5. Like 1. This is just compile time metadata, it can unambiguously be
made available at any point and position of the code.
—
Reply to this email directly or view it on GitHub
https://github.com/Microsoft/TypeScript/issues/3694#issuecomment-140996778
.

@impinball
One reason I'm mentioning this is because this proposal is relatively short sighted when it comes to allowing future extensions, like referencing the types of properties:
class Example {
  member: number;
  getMember(): this.member {
  ..
  };

  static member: string;
  static getMember(): this.member {
  ..
  }
}

If using different semantics at static and instance contexts, the problem then would be this.member at an instance position would mean the instance member (typed number) and typeof this.member at the same position would be static member (typed string). This would be very confusing. It also has the problem that it doesn't naturally extend to a way of referencing those types from the outside (this also includes function this type, which can be useful, especially if that function is used as a constructor).
In any case, having this mean the class type and typeof this mean the constructor type is also not great syntax in general.

@impinball
This problem also surfaces in the current proposal, regardless of any extensions, and even when this is entirely disallowed at static positions:
class Example {
  member: number;

  // Technically this should reference the static member's type. But other than the compiler
  // and those deeply familiar with the language spec, no one would guess this would be the case:
  func(): typeof this.member;

  static member: string;
}

@rotemdan
You're talking to someone who really doesn't like the idea of a this.prop type or similar. All I see is a gigantic footgun with no decent use case. Could you come up with a compelling, real-world example where the very idea itself could be useful?
// This should fail to compile. Happy hunting, even in this contrived example.
interface Foo {
  foo: string;
  member: this.foo;
  func(): this.member;
}

interface Bar extends Foo {
  bar: number;
  member: this.bar;
}

Do we really need to have strong implicit coupling between types?

@impinball
There is already a way to achieve strong implicit coupling between property types (although I wouldn't say it is very 'implicit'):
class Example {
  static a: string[];
  static b: typeof Example.a;
}

or more indirectly in interfaces (same approach can be use to reference class instance members):
interface A {
  a: number;
  b: typeof x.a; // Note this wouldn't work if A.a is a generic type.
}

let x: A;

More generally, any type alias is a essentially a strong coupling between types:
type A = number;
type B = A;
type C = B;
...
// Generic aliases (introduced in 1.6):
type A<T> = Array<T>;
type B<T> = { a: A<T> }
type C<T> = B<T>;
...

You don't have to use any of this if you think it is a bad practice. As for better syntax for property type references, see my proposal at #4640, which also includes a more constrained approach to a this type, that tries to address some of the issues I mentioned here.

In any case, this isn't really related to the issue of typeof this.member pointing to a static member type:

Modifying it to point to an instance member instead would change the semantics of this to reference the 'isolated' class instance type - a type that doesn't exist in typescript at the moment, and if this approach is taken, wouldn't be directly referenceable from the outside, though that would be possible with a simple trick:

class Example {
  a: this;
  static b: number;
}

let x: Example;

// The type of 'instance' is the isolated instance type of 'Example', which doesn't have a name
// or a way to describe it e.g. the closest way would be instance: { a: ??? }
let instance: typeof x.a;

Disallowing it completely (and also assuming it's disallowed at static positions) would weaken the class this type to the point it can only be used in very trivial cases, and wouldn't be loyal to the semantics of the containing class type.

@rotemdan

Do take into account that other than a standard this type to refer to the instance's type, the implementation will be hard.
I'm going to re-ask my question: could you demonstrate a real-world example of where this would be useful?

Not sure what is referenced as 'hard' to implement.
I'm not exactly sure what you are referring to, anyway, I was never mentioning that 'trick' for useful applications. The reason I mentioned that was because of semantic correctness:

class Example {
  func(): this {
    ...
  }

  a: number;
  static a: string;
}

let instance = new Example();
let x = instance.func();

Assuming this points to the isolated instance type of the class (i.e. typeof this.a refers to the instance member type) . What should the type of x be inferred here? would it be semantically correct resolve it to class type Example (where typeof Example.a would refer to a static member type)?
Also, if it is will be possible to declare:
class Example {
  static a: string;
  a: number;
  b: typeof this.a;
}

and have b reference to the instance property type, why not also allow to do this from the outside? (this includes references from anonymous interfaces within the class itself), but then any syntax that would be proposed would not be consistent with the typeof this syntax because typeof Example.a would point to the static property type. This is a part of the complex chain of reasoning that lead to formulating the typeon operator, as a more 'complete' package, that is consistent both for internal and external references.

@rotemdan Are you wanting this feature yourself?

@impinball I find myself using the Curiously recurring template pattern in most OO languages to represent this, which, in my opinion, is a hack workaround. Full fledged support for a this type would be immensely welcome.
:+1:

An implementation of polymorphic 'this' typing is now available in #4910.

@ahejlsberg Thanks, that's great. That request doesn't address the specification of a this type in functions yet? Does it?
e.g.
function f<this: {a: string}>() {
  return this.a;
}

+1

:+1: some browser apis define the custom this object.

+1

+1

:+1:  It's been a couple months since the last real discussion on this. Is there any updates?

@toadzky its been merged : https://github.com/Microsoft/TypeScript/pull/4910 :rose: And a few APIs in lib.d.ts have also been udpated

@basarat @toadzky I think that pull request just handles polymorphic types, but not the ability to set the the type of this as an argument for functions, for example:
function f<this extends {x:number}>() {
  this.x = 3;
  this.y = 6; //error: y is not available on this
}

@eggers That's what I've gotten as well. It's mostly for TypeScript's solution to the CRTP (example from Wikipedia):
// Java
public interface Comparable<T extends Comparable> {
    int compareTo(final T other);
}

public class Item implements Comparable<Item> {
    private String name;
    constructor(String name) {
        this.name = name;
    }

    @Override
    public int compareTo(final Item other) {
        return name.compareTo(other.name);
    }
}

// Scala
trait Comparable[T <: Comparable[_]] {
  def compareTo(other: T): Int
}

class Item(private val name: String) extends Comparable[Item] {
  def compareTo(other: Item): Int = name compareTo other.name
}

// TypeScript
interface Comparable {
    compareTo(other: this): number;
}

class Item extends Comparable {
    constructor(private name: string) {}

    compareTo(other: Item): number {
        return name.compareTo(other.name);
    }
}

The rest of it is still yet to be done.

As @impinball and @eggers noted #4901 only handles the class and interface case but not the function one. This is why the issue is still open. The next step is the ability to declare a constraint on the type of this argument in a function and check against that at call sites.

ok. I could really use that feature. i'm using koa, which binds everything to this when it invokes the handler function.

+1

+2

Hi, please merge following syntax into this discussion.
var o = {
  method() {
    this; // `this` is `o` object
  },
  anon: function () {
    this; // `this` is `o` object
  }
};

#5817

I put up a proposal for this-function types at #6018 (with a link to a prototype as well).

It appears #4910 did not address the possibility of typeof this though it did allow this in plenty of type expressions.
What was the resolution on that idea? It would allow for resolution of #3841 with syntax like:
class A {
	"constructor": typeof this;
}

let a = new A();
let b = new a.constructor();

@LPGhatguy see #1554 and #2542.

@LPGhatguy Also, as @ahejlsberg rightly mentioned here, not all JS constructors are well-behaved in this area. Too many people unintelligently do this (I admit I have a few times in small scripts and pages, out of laziness, but not in anything big):
function Foo() {
  // ...
}

Foo.prototype = {
  bar: function () {
    // ...
  },
}

In this case, new Foo().constructor === Object, because the object literal's constructor is Object. It was never actually set in the prototype object itself. That's the other problem.

We have:
class C {
  a: any
}
function fn(cb: (a:C) => void) {}
fn((c) => { c./code completion kicks in here/ })

Could we also have...?
function fn(cb: (this:C) => void) {}
fn(() => { this./code completion should kick in here/ })

@KamilSzot
Arrow functions don't have their own this, but inherit from the parent scope. I'm guessing you meant this?
function fn(cb: (this:C) => void) {}
fn(function () { this./* code completion should kick in here */ })

@KamilSzot @isiahmeadows I just wrote a test for what you want in my ongoing work to implement this for functions: 41d133f9fab6a58e6e2d303584f40c82b2446d9e
As Isiah points out, it only works with function, not =>.

with https://github.com/Microsoft/TypeScript/pull/6739, this types can be specified for functions. a new compiler flag, --noImplicitThis makes it an error if this is used without being defined in the containing function.

@mhegazy I have a couple clarification questions:

I'm guessing you're just referring to literal ES5 functions?
Does func(function (x: string) { ... }) trigger noImplicitThis if the callee doesn't define a this type for the argument, such as in func(f: (x: string) => any): any)?

Methods can also declare a this parameter:

class C {
  totalCallback(this: void, e: Event); // assign to me!
}

noImplicitThis is triggered by this expressions in the body of a function. It is independent of assignability checks, which default to any if no this type is declared.

In other this is an implicit this error:
function f(n: number) {
  return this.m + n; // error -- this: any
}

But this is a normal old assignability error:
function f(this: void) { ... }
class C {
    m(this: this) { ... }
}
let c: C;
c.m = f; // error!

@sandersn Thanks! :smile:

@sandersn Thanks! I think the approach to declare the first parameter as this: myType is the best one:

IMO the syntax is a bit verbose, instead of
function f<this extends {x:number}>() {
  this.x = 3;
}

why not simply:
function f() {
  let this: {x:number};
  this.x = 3;
}

@nippur72 no, that's not good. You're actually declaring a variable named this and not initializing it (undefined). The compiled code would have: var this; in it and have a runtime error

has this landed in 2.0 ? I just copied this in a 2.0 project:
function f<this extends {x:number}>() {
  this.x = 3;
}

but it tells me:

index.ts(1,12): error TS1139: Type parameter declaration expected.
index.ts(1,17): error TS1005: ';' expected.
index.ts(1,35): error TS1109: Expression expected.
index.ts(1,37): error TS1109: Expression expected.
index.ts(1,39): error TS1005: ';' expected.

@jonathandturner wrote:

function f<this extends {x:number}>() {
  this.x = 3;
  this.y = 6; //error: y is not available on this
}

Don't you mean implements instead of extends, since f is not allowed to add new member properties?

var o = {myMethod: f, y: "bob"};
o.myMethod(); //error: o does not match the shape of 'this' for 'myMethod'

Is new o.myMethod() legal?

Can we also propagate this to work with static functions?
Suppose, we have following code:

class C {
    constructor() { console.log("C"); }
    static foo() { return new this(); }
}

class D extends C {
    constructor() {
        super();
        console.log("D");
    }
    bar() { return 42; }
}

var d = D.foo(); // valid and works. Will output C and then D

console.log(d instanceof D);

console.log((<D>d).bar());

Can we add a possibility to type it correctly?

Of course you can. TypeScript has very advanced type system now.
class C {
  static foo = function <D extends C>(this: {new(): D}) {return new this()}
}

class D extends C {
  bar() { return 42}
}

var d = D.foo()
d.bar()

That looks like very dirty hack, although it works.

Is it possible to get the Type of my class I am currently working in? for example
export class A{
    // constructor + methods
    // can use `A` as a return Type
}
export class B extends A{
    public b:any = this;
    // here in my methods if I use a return type of `B` it implies class `A`type
    // how do I use `B` as a type?
    fun():B {
        const self = this.b;
        return self;  // Error: Type 'A' is not assignable to type 'B' , property 'some class var' is not in type 'A.
    }
}

@marcusjwhelan I think you want:
export class A {
}
export class B extends A {
    fun(): this {
        return this;
    }
}

https://egghead.io/lessons/typescript-create-a-fluent-api-using-typescript-classes :rose:

@basarat ah thank you for the quick reply. Although I actually figured out that it was fault code on my part. The reason I could not use the class as a type was an issue with me assigning the variable that was to be returned as the parent type, copy paste error.


multi-root workspace settings not using json w/comments mode

testing #39588
open a folder
file | add folder to workspace
open settings
result -> workspace settings language mode is JSON, not JSON with comments.

@sandy081 Instead of workspace.json, can you name the file workspace.code-workspace?
That way it would match the configured file extensions for jsonc1. I can also add workspace.json` but thought that this is quite a common name that might be used for regular JSON files as well.

@bpasero is creating this file on the main side for unsaved workspaces. Ben, over to you.

@sandy081 @aeschli please come up with another solution, there are untitled workspaces for all our multi root users called workspace.json so this would not be a solution. If it helps, these files are all in a well known location (workspacesHome).

@aeschli yes, comments do not error and i can have trailing commas

Then it's just the editor language mode that is lying, as with other files. Closing as ok.


Remove redundant request_timeout on compiler_rest_transport from tests (#3170)

Pull request opened by the merge tool on behalf of #3170

Merged into branches iso3 in e53842f589b41a1606d28d79a63e44369887ddd2


 See https://github.com/silverstripe/silverstripe-asset-admin/actions/runs/4887239565/jobs/8724358629 for an example.
Here's the output which might be relevant from that job (in the "Stop containers" section), in case the log is removed:

2023-05-04 21:41:57+00:00 [Note] [Entrypoint]: Initializing database files
Warning:  2023-05-04T21:41:57.046460Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
Warning:  2023-05-04T21:41:57.324474Z 0 [Warning] InnoDB: New log files created, LSN=45790
Warning:  2023-05-04T21:41:57.419773Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
Warning:  2023-05-04T21:41:57.475925Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7e79def9-eac4-11ed-a6d7-0242ac120002.
Warning:  2023-05-04T21:41:57.477418Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
Warning:  2023-05-04T21:41:57.897368Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
Warning:  2023-05-04T21:41:57.897441Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
Warning:  2023-05-04T21:41:57.897940Z 0 [Warning] CA certificate ca.pem is self signed.
Warning:  2023-05-04T21:41:57.907801Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2023-05-04 21:42:00+00:00 [Note] [Entrypoint]: Database files initialized
2023-05-04 21:42:00+00:00 [Note] [Entrypoint]: Starting temporary server
2023-05-04 21:42:00+00:00 [Note] [Entrypoint]: Waiting for server startup
Warning:  2023-05-04T21:42:01.137757Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
.....
2023-05-04T21:42:01.252004Z 0 [Note] InnoDB: 5.7.42 started; log sequence number 2766912
2023-05-04T21:42:01.252881Z 0 [Note] Plugin 'FEDERATED' is disabled.
2023-05-04T21:42:01.258850Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2023-05-04T21:42:01.258874Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
Warning:  2023-05-04T21:42:01.258878Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
Warning:  2023-05-04T21:42:01.258880Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
Warning:  2023-05-04T21:42:01.259424Z 0 [Warning] CA certificate ca.pem is self signed.
2023-05-04T21:42:01.259463Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2023-05-04T21:42:01.259797Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2023-05-04T21:42:01.261271Z 0 [Note] InnoDB: Buffer pool(s) load completed at 230504 21:42:01
Warning:  2023-05-04T21:42:01.270446Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2023-05-04T21:42:01.277860Z 0 [Note] Event Scheduler: Loaded 0 events
........
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2023-05-04 21:42:03+00:00 [Note] [Entrypoint]: Creating database SS_mysite
.............
2023-05-04 21:42:05+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
Warning:  2023-05-04T21:42:06.189831Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-05-04T21:42:06.191168Z 0 [Note] mysqld (mysqld 5.7.42) starting as process 1 ...
........
2023-05-04T21:42:06.272026Z 0 [Note] InnoDB: Buffer pool(s) load completed at 230504 21:42:06
2023-05-04T21:42:06.279772Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2023-05-04T21:42:06.279787Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
Warning:  2023-05-04T21:42:06.279791Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
Warning:  2023-05-04T21:42:06.279793Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
Warning:  2023-05-04T21:42:06.280329Z 0 [Warning] CA certificate ca.pem is self signed.
2023-05-04T21:42:06.280359Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2023-05-04T21:42:06.280633Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2023-05-04T21:42:06.280662Z 0 [Note] IPv6 is available.
2023-05-04T21:42:06.280672Z 0 [Note]   - '::' resolves to '::';
2023-05-04T21:42:06.280687Z 0 [Note] Server socket created on IP: '::'.
Warning:  2023-05-04T21:42:06.281663Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2023-05-04T21:42:06.288748Z 0 [Note] Event Scheduler: Loaded 0 events
2023-05-04T21:42:06.289478Z 0 [Note] mysqld: ready for connections.
Version: '5.7.42'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
2023-05-04T21:42:06.779912Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2023-05-04T21:42:16.887704Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2023-05-04T21:42:26.957482Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO)
... that error repeats a few more times
Stop and remove container: c655322f95044ea98c506d2698f4c147_mysql57_7aeb6e
/usr/bin/docker rm --force a00c2b06c181244c1f6c34f6772a09e2a12a3cfb0c6a71150baef3c128bba83f
a00c2b06c181244c1f6c34f6772a09e2a12a3cfb0c6a71150baef3c128bba83f
Print service container logs: 509ac507163d4f5ca8004212eb6ae177_mysql80_462b3e
/usr/bin/docker logs --details 9e05d60c08688267ce7f5a336a8240582edae7ecad5c8e19c686953d6af238e9
2023-05-04 21:42:09+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started.
Warning:  2023-05-04T21:42:09.409447Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-05-04T21:42:09.409543Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.33) initializing of server in progress as process 79
2023-05-04T21:42:09.415771Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-04T21:42:09.763857Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
Warning:  2023-05-04T21:42:10.933759Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
Warning:  2023-05-04T21:42:14.227124Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-05-04T21:42:14.229103Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.33) starting as process 121
2023-05-04T21:42:14.242714Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-04T21:42:14.551245Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
Warning:  2023-05-04T21:42:14.824803Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-05-04T21:42:14.824887Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
Warning:  2023-05-04T21:42:14.826532Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2023-05-04T21:42:14.843252Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.33'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server - GPL.
2023-05-04T21:42:14.843526Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2023-05-04T21:42:16.902522Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.33).
2023-05-04T21:42:18.265487Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.33)  MySQL Community Server - GPL.
Warning:  2023-05-04T21:42:19.198110Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-05-04T21:42:19.199430Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.33) starting as process 1
2023-05-04T21:42:19.205964Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-04T21:42:19.556766Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
Warning:  2023-05-04T21:42:19.795178Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-05-04T21:42:19.795228Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
Warning:  2023-05-04T21:42:19.796600Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2023-05-04T21:42:19.825370Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
.........
waiting for server to start....2023-05-04 21:42:20.907 UTC [47] LOG:  starting PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-05-04 21:42:20.908 UTC [47] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-05-04 21:42:20.911 UTC [50] LOG:  database system was shut down at 2023-05-04 21:42:20 UTC
2023-05-04 21:42:21.152 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-05-04 21:42:21.153 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-05-04 21:42:21.156 UTC [61] LOG:  database system was shut down at 2023-05-04 21:42:21 UTC
2023-05-04 21:42:21.160 UTC [1] LOG:  database system is ready to accept connections
2023-05-04 21:42:30.195 UTC [73] FATAL:  role "root" does not exist
2023-05-04 21:42:40.293 UTC [81] FATAL:  role "root" does not exist
2023-05-04 21:42:50.392 UTC [90] FATAL:  role "root" does not exist
2023-05-04 21:43:00.491 UTC [99] FATAL:  role "root" does not exist
...... that error repeats a few more times

We don't think this is causing any builds to fail. The warnings seems mostly harmless.


chore: Add Literal typing for mode and projection_types

Feature or Bugfix

Refactoring

Detail

Add usage of Literal for writing modes such as Literal["overwrite", "append"]
Change projection_types to Literal["enum", "integer", "date", "injected"]

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

AWS CodeBuild CI Report

CodeBuild project: GitHubDistributedCodeBuild6-jWcl5DLmvupS
Commit ID: 52c2a061a575be54434f770bcaa66d9dd9f299f8
Result: FAILED
Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

AWS CodeBuild CI Report

CodeBuild project: GitHubDistributedCodeBuild6-jWcl5DLmvupS
Commit ID: 118507abb4c45ae2e3597bd042cd53ea92ad8cd0
Result: FAILED
Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

AWS CodeBuild CI Report

CodeBuild project: GitHubCodeBuild8756EF16-4rfo0GHQ0u9a
Commit ID: 118507abb4c45ae2e3597bd042cd53ea92ad8cd0
Result: FAILED
Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

AWS CodeBuild CI Report

CodeBuild project: GitHubDistributedCodeBuild6-jWcl5DLmvupS
Commit ID: b98fa5e90694e3e35c50623a93695e520376f3a3
Result: FAILED
Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

AWS CodeBuild CI Report

CodeBuild project: GitHubCodeBuild8756EF16-4rfo0GHQ0u9a
Commit ID: b98fa5e90694e3e35c50623a93695e520376f3a3
Result: FAILED
Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

AWS CodeBuild CI Report

CodeBuild project: GitHubDistributedCodeBuild6-jWcl5DLmvupS
Commit ID: b98fa5e90694e3e35c50623a93695e520376f3a3
Result: FAILED
Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

AWS CodeBuild CI Report

CodeBuild project: GitHubDistributedCodeBuild6-jWcl5DLmvupS
Commit ID: a5242d3bcfb476289392490af9ba30240504da59
Result: SUCCEEDED
Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

AWS CodeBuild CI Report

CodeBuild project: GitHubCodeBuild8756EF16-4rfo0GHQ0u9a
Commit ID: a5242d3bcfb476289392490af9ba30240504da59
Result: SUCCEEDED
Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

AWS CodeBuild CI Report

CodeBuild project: GitHubDistributedCodeBuild6-jWcl5DLmvupS
Commit ID: 425714230f366225034f7c24c85b8c2bbc6520c8
Result: SUCCEEDED
Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository


It is an active send, for example, a message with a specified content is sent to all connected clients every 5 seconds.

https://github.com/jchristn/SuperSimpleTcp/issues/197
In addition, I found a solution to this:
_Server = new SimpleTcpServer("<IP_ADDRESS>", 1236)

Hi @FreeVB you can use the server GetClients() method and then iterate, sending each a message.  Broadcast functionality is not built into the library.


biodownloader crashes when directory does not exist yet

biodownloader should create a new directory if it does not exist yet, but
running this
datadir = "data";
final IBioDownloader bioDownloader = new BioDownloaderBuilder(Path.of(datadir))
                .hpoJson()
                .hpAnnotation()
                .build();

leads to
23:55:28.511 [main] ERROR org.monarchinitiative.biodownload.BioDownloaderBuilder - Path must be a directory.
Directory must be writable.

java.lang.IllegalStateException: Path must be a directory.
Directory must be writable.

	at org.monarchinitiative.biodownload.BioDownloaderBuilder.validate(BioDownloaderBuilder.java:204)
	at org.monarchinitiative.biodownload.BioDownloaderBuilder.build(BioDownloaderBuilder.java:182)
	at org.monarchinitiative.myphenomizer.cmd.DownloadCommand.call(DownloadCommand.java:29)
	at org.monarchinitiative.myphenomizer.cmd.DownloadCommand.call(DownloadCommand.java:12)
	at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
	at picocli.CommandLine.access$1300(CommandLine.java:145)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
	at picocli.CommandLine.execute(CommandLine.java:2078)
	at org.monarchinitiative.myphenomizer.Main.main(Main.java:22)

Process finished with exit code 1

If I create the directory by hand, biodownloader works perfectly.

fixed


#42 Fixed too much maker notes entries on panasonic

#42
The number of entries here was like 1644.
Problem is that it is not async, so it just cause memory leak :(.
So i fixed it simply like this, I am sure you'll find better way :)
Thank you for this exif reader, great thing, I would be screwed without. I owe you a beer:)

@vojtatranta my PR already fixed this https://github.com/gomfunkel/node-exif/pull/38

Fixed by version 0.5.0
https://github.com/gomfunkel/node-exif/releases/tag/0.5.0

@Sitebase do you want me to confirm it?

yes please :-)
2016-01-20 17:24 GMT+01:00 vojtatranta<EMAIL_ADDRESS>
@Sitebase https://github.com/Sitebase do you want me to confirm it?
—
Reply to this email directly or view it on GitHub
https://github.com/gomfunkel/node-exif/pull/43#issuecomment-173259964.


feat: add provider.decodeParameters

Motivation and Resolution
Solve issue #929
Add a method that decodes a list of field elements into Javascript objects.
Usage related changes
myCallData.decodeParameters() has been added :
const helloCallData=new CallData(compiledSierra.abi);
const res2=helloCallData.decodeParameters("hello::hello::UserData",["0x123456","0x1"]);
const res3=helloCallData.decodeParameters(
    ["hello::hello::UserData","hello::hello::UserData"],
    ["0x123456","0x1","0x98765","0x0"]
);

Development related changes
A method has been added to the CallData class.
@penovicp : this PR is based on v6.0.0-beta.11, and will merge in beta branch. Frederico would like to have it also in v5 ; I don't know exactly how to handle this case.
Checklist:

[x] Performed a self-review of the code
[x] Rebased to the last commit of the target branch (or merged it into my branch)
[x] Linked the issues which this PR resolves
[x] Documented the changes in code (API docs will be generated automatically)
[x] Updated the tests
[x] All tests are passing

@penovicp : this PR is based on v6.0.0-beta.11, and will merge in beta branch. Frederico would like to have it also in v5 ; I don't know exactly how to handle this case.

@PhilippeR26 I apologise for getting late to this, I was away when you asked and the SNIP-12 PR was a priority once I was back. To answer your question, since the all the used features of the code were present in v5 a git cherry-pick of the relevant commit was sufficient to enable a backport which was done with #945.


Datasource Request: Debian ELTS Advisories

Source: https://www.freexian.com/lts/extended/updates/
Republished in OSV format at https://github.com/captn3m0/debian-elts-advisories/
I'm happy to add a index JSON as well, if needed - but it would probably be easier to ingest via the git repo.
Sample advisory URL: https://captnemo.in/debian-elts-advisories/advisories/ELA-1178-1.json

@captn3m0, the patch provided by Freexian is not free, right?
Also they don't seem to have any license for their advisory here https://salsa.debian.org/freexian-team/extended-lts/security-tracker. Maybe we should mail them to confirm the license for their advisories.

I think the repos are available to use: https://www.freexian.com/lts/extended/docs/how-to-use-extended-lts/, but the supported package list is determined by the sponsors.
I'm not sure if the patches are published.

@captn3m0 Thanks for the clarification. In that case, we just need to confirm the license of the advisory data.


Shell isn't set during setup

When the automatic setup runs the shell isn't set. This is present in the current release. Untested in master.

This seems to be fixed in master. Here's what I tested
fresh start => always chooses $SHELL This seems to save properly in both version
update settings => this seems to omit saving, or saves an empty string. But, this seems to work on master.

Ah perfect. We should just cut a new release to get the fix then. I'll go ahead and close this.


Nuttx missing tag nuttx-7.21 in repo

@dagar I just noticed that ver is displaying  7.21.0, so I think the tag from  nuttx-7.22 git dropped.
OS: NuttX
OS version: Release 7.21.0 (118817023)
Would you re-assign it from the commit on BB or change the parser to use the highest  tag in the form 'upstream_7.22+'?

What do we need the upstream_X.Y+ tags for? Can we do it automatically from the real nuttx tags?
We're currently missing the nuttx-7.22 tag.
https://github.com/PX4-NuttX/nuttx/releases

upstream_X.Y+  It represents the point in upstream we added are patches on and "tied" Firmware too.

I do not think we can. Tags from upstream are on the release, but immediately there are commits, hence the +.

I pushed the missing upstream_7.22+.


Update README.md: Add "getting started" section

Added "getting started" section in README.md file

Refers to Issue #20


fix: exclude pods holding a DeletionTimestamp when populating cluster.Status.InstancesStatus

Closes #5208

https://github.com/EnterpriseDB/cloudnative-pg/actions/runs/10215314666

/ok-to-merge e2e are green


Feature request: Knight orientation

I plan to modify the models to rotate the knights on the vertical axis -90°, as illustrated below, viewed from the white side of the board. I can make that change in my local copy of the resourcepack (which I have merged into my larger resourcepack), but you might want to make rotation a configurable option instead.

I gave editing the JSON a try, but it's too complex for me (I tried changing the cardinal points -- north, east, south, west -- by by one step, but it didn't change the presentation). If you're willing, please give me a modified chess_knight_black.json and chess_knight_white.json that perform this magic.


Fully remove MUI (tech debt)

User Story
As a user, I want a consistent UI design so that the design makes sense without meaningless confusing differences.
Description
We are moving from MUI to Shadcn/Tailwind.
Implementation idea
Remove any remaining MUI components and unnecessary packages.

Is this a duplicate of #937?

Yes, good catch, Sebastian!

Duplicate of #937


Update User

Right now in the update user section it says Stamplay.User.get when (I believe) it should say Stamplay.User.update.

You are correct, fixed! Thanks!


Allow platform to be absent in customized device config

So for certain hidden customized device config we can only leave useful key-value pair in config file.

Notes: listBrowsers() crashes when it can't grab the length of fields that don't exist. This pesky bug needs to be fixed in a nice way once and for all.


Clean up dependencies

Unused dependencies:
elliptic
ethereumjs-tx
express
fs-extra
ganache-cli (perhaps this should have been there as a devDependency and an associated script?)
grpc-web
keccak
truffle-contract
web3

Missing dependencies:
@ethersproject/units
chai
ethers
lodash

I did not review the usage of any dependencies beyond whether they're required or not


Input prompts are truncated

Before submitting your bug report

[ ] I believe this is a bug. I'll try to join the Continue Discord for questions
[X] I'm not able to find an open issue that reports the same bug
[X] I've seen the troubleshooting guide on the Continue Docs

Relevant environment info
- OS:windows 11
- Continue version:0.8.55
- IDE version:
- Model:Rombos-Qwen2.5-Coder:32b

Description
Use ctrl+l to select a longer code, then enter a longer cue word the entire cue word will be truncated, enter a shorter cue word the entire cue word is not truncated
Longer prompts:请对以下代码进行重构，以提高其简洁性、效率和逻辑优化。请遵循以下步骤：1. 提供重构后的完整代码，使用markdown格式。2. 详细说明重构后的代码与原始代码的区别，包括：结构改进、逻辑优化、效率提升、代码简化。3. 解释每项重要修改的原因和好处。4. 确保回答简洁明了，避免重复或无关内容。请使用简体中文回答。以下是需要重构的代码：\n\n{{{ input }}}
Shorter prompts:重构以上代码

To reproduce
No response
Log output
No response

I found that when role is system, the prompt is normal, but when role is user, the prompt is truncated.

Before set maxTokens for 12000, contextLength for 13000 results of the prompt word was truncated, now set maxTokens for 12000, contextLength for 32000 prompt word is normal ......

This is largely intentional behavior—we are forced to truncate something if the context goes over the limit, otherwise the API will just error out. We have to add maxTokens to the context length calculation because this is what all LLM APIs do in their calculation

I made an adjustment here so that we can warn users when this might happen: https://github.com/continuedev/continue/pull/2937/commits/b614c43f8dc791e5a1358dfa77c0de0cc9d845bf


CDN link for v2.x?

Description
what's the CDN link for v2?
the following link:
<EMAIL_ADDRESS>results in:
Cannot find "/dist/fireworks.js" in<EMAIL_ADDRESS>and
<EMAIL_ADDRESS>links to v1.4.1
Which package are you using?
fireworks-js
fireworks-js version
1.4.1
Browser
Chrome

Using a fixed version:
<EMAIL_ADDRESS><EMAIL_ADDRESS>or latest:
https://unpkg.com/fireworks-js@latest
https://cdn.jsdelivr.net/npm/fireworks-js@latest

thanks for your help. I'm a bit of a hack so you'll have to bear with me as I move from 1.4.1 to 2.10.0. I'm using<EMAIL_ADDRESS>but getting:
Uncaught TypeError: Fireworks is not a constructor
for
fireworks = new Fireworks(container,{});

for some reason now it is in window
new window['fireworks-js'].Fireworks(container)
it was my mistake to rename the file from version 2.0. better to use fixed version in cdn's

upd:

@BartmanEH
the best way to used via cdn for latest version :shrug:

@BartmanEH https://codesandbox.io/s/loving-lederberg-4tdfiy?file=/src/index.ts

OK, thanks to your help, I'm back to where I was: fireworks working but using v2.10.0 instead of v1.4.1
I think the readme needs an update to usage section to show:
const fireworks = new Fireworks.default(container, { /* options */ })
instead of
const fireworks = new Fireworks(container, { /* options */ })
but I still cannot get updateOptions to work. I moved it to after .start() but still fireworks.updateOptions({ traceSpeed: 1 }); has no effect.

OK, I think it's all working now. Thanks for your help. I do wish I could make is slower than traceSpeed = 1 :-)

fireworks.updateOptions({ traceSpeed: 1 }); in my application is no where near as slow as in your sandbox example.


i18n(es): Testing

What kind of changes does this PR include?

Minor content fixes (broken links, typos, etc.)
Changes or translations of Starlight docs site content
Changes to Starlight code
Something else!

Description

Closes #
What does this PR change? Give us a brief description.
Did you change something visual? A before/after screenshot can be helpful.

Perfect, now it works, I close the PR


citogo: timeout after 60s on each individual test

thanks, i'm pretty sure this'll pass CI. I hope it does, otherwise, that's an issue that's good to know about.

Passed, but unfortunately jenkins doesn't trigger all the tests when this script changes.  Oh well, YOLO I guess!

Good point, I should change it to rerun everything as it does when you update jenkinsfile


There is a problem with image area selection

Thank you for your great work. There is still a writing problem when selecting the image area. The lower part that is not selected will be seriously blurred. What is the reason for this?

Hi @823863429, the mask region is automatically generated by the Gradio. Can you check the image and the mask are correctly aligned? (You can use pickle to save the image & mask processed by Gradio and then check them in the notebook). I have been testing it on a Ubuntu Linux, have not been tried it on other platform, which OS are you using?

I have check the mask，only the fire place，I use the Ubuntu Linux

@823863429 Can you share the image, I can try to debug. Also, have you resized the image or did anything to change the image within gradio?

sorry ，I did not save the image

@cplusx If it is a 1:1 ratio picture, how to generate a video?

@823863429 Can you share the image, I can try to debug. Also, have you resized the image or did anything to change the image within gradio?

The lower part that is not selected will be seriously blurred. What is the reason for this?


Cannot see the whole dropdown on nsfwjs.com

Just FYI, on https://nsfwjs.com, it's impossible to see the bottom of the dropdown because the page cannot be scrolled.

Have a good day

fixed and deployed


New pyinstaller GitHub Actions

This pull request brings new .yml files in .github/workflows: particularly, actions that use pyinstaller to create binaries containing everything that tidal-wave needs to run: Python interpreter, Python dependencies, and an FFmpeg binary.
Work on the latter continues, as the binaries compiled are still rather large, and it's not clear exactly what minimal feature set is needed for the few file formats that tidal-wave interacts with.

Woosh! That looks fantastic! 2 min build time vs 8 min!

My name is Kiril Gantchev, I'm the CEO and co-founder of FlyCI. Thanks for giving FlyCI a try. I hope you enjoy it and please feel free to reach out should you have any issues.
Best Regards,
Kiril Gantchev
Discord: FlyCI | Twitter: flyciapp | LinkedIn: FlyCI

Hi,
the latest release 2024.1.13 is missing the pyapp self-bootstrapping Windows binary. Can you please provide it?

@eevan78 thank you for having pointed this out! I had not noticed that the automation had failed, so I will get it uploaded shortly.
Next time, can you raise an issue instead of commenting on the PR? That just helps me track things better.

Hi @ebb-earl-co,
Thanks for continuing to use FlyCI. We would love to feature your feedback on our website and add PowerGridModel to our case studies section. It will highlight your project to our visitors and it will help us grow our community. Would you mind sharing a few thoughts?
If you're OK with it, then I have a few quick questions that will help me prepare the case study:

What motivated your choice to use FlyCI's MacOS runners, and what key benefits have you observed? (Performance, compatibility, etc.)
What has been your experience with the FlyCI runners so far?
What improvements have you noticed since integrating FlyCI's MacOS runners? (e.g., performance enhancements, reduced build times, developer productivity, cost savings)


Main editor toolbar icons are blurry

Tested versions

Reproducible on 4.3-dev3

System information
Godot v4.3.dev3 - Ubuntu 22.04.3 LTS 22.04 - X11 - Vulkan (Mobile) - integrated Intel(R) Iris(R) Plus Graphics (ICL GT2) () - Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz (8 Threads)
Issue description
The icons on the main toolbar are blurry.

You can compare with those from the side palette which are drawn correctly. The three-dot "more" icon is a good point of comparison.
Steps to reproduce
Create a new project and see the main editor window. Make sure you run a non-hidpi  setup with 1920x1080 monitor, and OS scaling setting ideally set to 100% for instance, to avoid any default upscaling taking place which would make the issue not visible.
Minimal reproduction project (MRP)
N/A, sufficient to open an empty project in the editor

Non-integer spacing somewhere?
There has been a complete refactoring of the editor theme generation with emphasis on margins/spacings. Could this be a side effect?

I can certainly confirm the issue. it is difficult to visualize a comparison, but something has changed and they definitely look blurrier as a result.

Just found this today as well. Also not sure where this comes from, resizing does not fix it.

A quick comparison of versions:

My guess is that it's related to SVG_Renderer from Freetype.
It was update here https://github.com/godotengine/godot/commit/008d3de1e9387720c16820adb5858e5a1278762b last time, so since 4.2.1 it's probably an issue.
I'm not a C developer. Maybe @bruvzg could help us confirm this bug is related to Freetype update. By the way, sorry for bothering you (tagging).

My guess is that it's related to SVG_Renderer from Freetype (this file, maybe? godot/thirdparty/freetype/src/svg/ftsvg.c)

No, FreeType is not related to the icons in any way. Most likely it's something with icon positions (theme or control changes).

Interesting find!
Then we should look for drawing code that puts images at non-integer coordinates. This is a probable culprit.
UI toolkits of long ago may have had logic that automatically snap images and primitives to the nearest pixel. In Godot, if you draw something between pixels, it gets blurry. Rounding coords to the closest pixel after calculation may be a solution.
One suggestion would be to recommend checking the result on non-hidpi displays every time there is UI code being worked on. Perhaps add a little mention in the developer docs about that? Because someone who only works on 4K/Retina/hidpi or similar screens would never see the issue on his configuration.


Define how QuickStarts can be surfaced on the Dev Site in Virtouso and NR1

We are wanting to turn this https://newrelic.github.io/nr1-quickstarts/#/ into a proper section on the developer site, so it's easy to use, maintain and follows are standards for developer how tos and guides.
Quick starts may eventually be added to the Virtuoso install workflow, so there will be some desire to unify this expeirence with whatever is introduced to that flow.
Finally, it would make sense to surfacing in the NR1 Product as currently they are found under 3rd party apps which isn't so intuitive.
Design Ideas & Tasks

Add a primary nav item Quick Starts
Decide on new icon for Quick starts
Follow the pattern established by Build Apps which has

a intro paragraph
a intro video
tiles that highlight each quick start item and link to the quick start repositories
We will probably want an index page that uses this content found here

Additional info & feedback
There is a listing quickstarts here and instructions on how to set these up here. This uses a 3rd party app you add to the catalog (which doesn't work on my test account) 🤷
So it's very disjointed at the moment and it's really hard to follow what we are expecting user to do here.
possible Virtuoso workflow

run the installer in the UI or CLI
make all your installer selections
pick your pre-built dashboards from a list of available ones
Get linked into to the product.
find New Relic Joy.

Guided Install eventually if you want to use our sandbox to replicate fake production data you can, instead of installing on your own infrastructure.
other ideas
when a user clicks on create a dashboard or import a dashboard in the NR1 Product, why not let them select a quickstart dashboard?

Import

Create

One assumption (that needs to be verified if that’s in the scope of the Virtuoso team):

Quickstarts will be part of the install recipe (see example here)
This means there is a static GitHub link baked into the install recipe itself.
This way, a user automatically gets a recommended quickstart installed.
This means that for the initial in-product XP I suggest we call out what quickstart was deployed, and potentially draw attention how more quickstarts can be deployed (by refering to the quickstarts NR1 app, which should become native) or customized/contributed (by refering to the GitHub repo)
This makes the initial in-product XP a lot simpler. As part of the New Relic Sandbox work, we can build 1 great quickstart, but we will need to support from the community to contribute more and build a true ecosystem.

About your other suggestion when a user clicks on create a dashboard or import a dashboard in the NR1 Product, why not let them select a quickstart dashboard? I believe this is on the roadmap for the dashboard team, but will check.

we've done this work in our requirments doc, so closing this issue.


As a service author, I can perform custom operations on update service

GIVEN that app broker is configured to reconfigure an application on update service
WHEN an implementing broker contributes a bean to the app context that adheres to an app broker interface
THEN the broker-provided bean will be invoked along with the app update operations provided by app broker

Hi @scottfrederick , @royclarkson - I added this issue just so we have something to track dependencies on from the config server project. If it doesn't make sense please feel free to amend or delete it!


test failure on fixed version

Hi,
when I run defects4j test on Chart bug 1 fixed version, I got an unexpected failure.
Failing tests: 1
  - org.jfree.chart.annotations.junit.XYImageAnnotationTests::testPublicCloneable

The executed commands are as following:
(base) root@e4f9a758f41b:/home/hanjiachen/workspace/defects4j# defects4j checkout -p Chart -v 1f -w ./Chart_1_fixed
(base) root@e4f9a758f41b:/home/hanjiachen/workspace/defects4j/Chart/Chart_1_fixed# defects4j test

My environment is
PWD.........................../home/hanjiachen/workspace/defects4j/Chart/Chart_1_fixed
SHELL.........................(none)
TZ............................America/Los_Angeles
JAVA_HOME.....................(none)
Java Exec...................../usr/bin/java
Java Exec Resolved............/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Java Version:
  openjdk version "1.8.0_362"
  OpenJDK Runtime Environment (build 1.8.0_362-8u362-ga-0ubuntu1~18.04.1-b09)
  OpenJDK 64-Bit Server VM (build 25.362-b09, mixed mode)
Git version...................git version 2.17.1
SVN version...................1.9.7
Perl version..................v5.26.1

why I got such test running results, can you help me to fix this problem?
Thanks,
Jiachen

Thanks for your bug report.  I am sorry you are having trouble.
Unfortunately, I am unable to reproduce your problem.  Here is the output that I get:
% defects4j checkout -p Chart -v 1f -w ./Chart_1_fixed
Checking out 2266 to /home/mernst/research/testing/defects4j-branch-master/ OK
Init local repository...................................................... OK
Tag post-fix revision...................................................... OK
Apply patch................................................................ OK
Run post-checkout hook..................................................... OK
Excluding broken/flaky tests............................................... OK
Excluding broken/flaky tests............................................... OK
Initialize fixed program version........................................... OK
Apply patch................................................................ OK
Initialize buggy program version........................................... OK
Diff 2266:2264............................................................. OK
Apply patch................................................................ OK
Tag pre-fix revision....................................................... OK
Check out program version: Chart-1f........................................ OK

% cd ./Chart_1_fixed

% defects4j test
Running ant (compile.tests)................................................ OK
Running ant (run.dev.tests)................................................ OK
Failing tests: 0

In order to permit reproducing (and fixing!) your problem, could you please provide a set of commands that can be cut-and-pasted into a shell?
The first command should be
git clone https://github.com/rjust/defects4j.git
Thanks.

Thank you for your reply, this issue has been resolved.
After cloning and running the test again, I found the problem did not occur.
Thanks.


Trace level should be configurable

This is two related feature requests.
First, it would be nice if it were possible to control the verbosity of the server traces. Currently, they are either on or off. But it would be nice to have an intermediate level, where the time/direction/method/id were logged, but the body/params/etc. were NOT.
Second, it would be nice to be able to control the trace level at runtime, so that traces could be turned on momentarily.
The LSP spec has outlined how to do both of these things.
It defines TraceLevel, an enum of 'off', 'messages' and 'verbose'. (I think our current traces map to 'off' and 'verbose', so I would like to add 'messages'.)
The initial level can be set in the InitializationParams as trace. During the lifetime of a server the TraceLevel can be changed with a $/setTrace notification. (Calva sends this notification when you change the trace level in the Calva settings window, though lsp4clj and clojure-lsp ignore it. I think the intention is to have a single setting that controls both the client and server trace level. I haven't noticed the notification from other editors, though they may send it too.)
I'm starting this Issue here in lsp4cl. It will need to generate traces that respect the trace level. And it will need some way of being told what the trace level should be. But clojure-lsp will have some responsibility too... I think it should handle the initialize and $/setTrace messages, and instruct lsp4clj what to do. I think it's better that the language servers handle these messages, because they may want to make their own decisions both about lsp4clj's trace level, but also about their own logging.

Ensure server is initialized with a trace-ch, to be prepared for level changes
Initialize server with a (stateful) trace level, defaulting to 'off'
Skip tracing if trace level is 'off`. Modify trace contents based on whether level is 'messages' or 'verbose'
Add lsp4clj.protocols.endpoint.IEndpoint/set-trace-level, and use it to modify trace level
(clojure-lsp) Call set-trace-level during initiailize
(clojure-lsp) Call set-trace-level upon $/setTrace

The new --trace option in clojure-lsp may still be useful, to control tracing before the initialize message.

Sounds great! I think I missed that from spec.
We could start supporting it on lsp4clj/clojure-lsp and change most used editors to support it, I can help with lsp-mode if needed


Slack Hero Buttons Clicks Do Not Include Original Message Text

Hi! I'm using the C# BotFramework 4.12.2. In the code sample below, I also use Microsoft.Bot.Builder.Dialogs 4.12.2 to generate the choice buttons.
Rendering the buttons (actually, Hero cards) works great! But when a user clicks on them...
public class MetaBot : ActivityHandler
{
    protected override async Task OnMessageActivityAsync(
        ITurnContext<IMessageActivity> turnContext,
        CancellationToken cancellationToken)
    {
        if (turnContext.Activity.Text.EndsWith("test", StringComparison.Ordinal))
        {
            var reply = ChoiceFactory.ForChannel(
                turnContext.Activity.ChannelId,
                new List<Choice>
                {
                    new("Red"),
                    new("Blue"),
                    new("Green")
                },
                "choose a color!");
            reply.Text = "You have choices";
            await turnContext.SendActivityAsync(reply, cancellationToken);
            return;
        }

        if (turnContext.Activity.Text is "Red" or "Blue" or "Green")
        {
            var channelData = JsonConvert.SerializeObject(turnContext.Activity.ChannelData, Formatting.Indented);
            var reply = new Activity("message")
            {
                Text = $"You chose {turnContext.Activity.Text}\n\n{channelData}"
            };
            await turnContext.SendActivityAsync(reply, cancellationToken);
            return;
        }
    }
}

This is the response:
You chose Blue
{
 "Payload": {
   "type": "interactive_message",
   "actions": [
     {
       "name": "imBack",
       "type": "button",
       "value": "Blue"
     }
   ],
   "callback_id": "REDACTED",
   "team": {
     "id": "T013108BYLS",
     "domain": "aseriousbiz"
   },
   "channel": {
     "id": "C01A3DGTSP9",
     "name": "abbot-dev-playground"
   },
   "user": {
     "id": "U012LKJFG0P",
     "name": "haacked"
   },
   "action_ts": "1620771671.767135",
   "message_ts": "1620771661.004500",
   "attachment_id": "2",
   "token": "REDACTED",
   "is_app_unfurl": false,
   "enterprise": null,
   "is_enterprise_install": false,
   "original_message": {
     "bot_id": "B014DK3ARS5",
     "type": "message",
     "text": "",
     "user": "U013U8MQV8W",
     "ts": "1620771661.004500",
     "team": "T013108BYLS",
     "bot_profile": {
       "id": "B014DK3ARS5",
       "deleted": false,
       "name": "Costello",
       "updated":<PHONE_NUMBER>,
       "app_id": "A014QR5UQMN",
       "icons": {
         "image_36": "https://a.slack-edge.com/80588/img/plugins/app/bot_36.png",
         "image_48": "https://a.slack-edge.com/80588/img/plugins/app/bot_48.png",
         "image_72": "https://a.slack-edge.com/80588/img/plugins/app/service_72.png"
       },
       "team_id": "T013108BYLS"
     },
     "attachments": [
       {
         "callback_id": "REDACTED",
         "text": "choose a color!",
         "id": 1,
         "fallback": "choose a color!"
       },
       {
         "callback_id": "B014DK3ARS5:T013108BYLS",
         "id": 2,
         "actions": [
           {
             "id": "1",
             "name": "imBack",
             "text": "Red",
             "type": "button",
             "value": "Red",
             "style": "default"
           },
           {
             "id": "2",
             "name": "imBack",
             "text": "Blue",
             "type": "button",
             "value": "Blue",
             "style": "default"
           },
           {
             "id": "3",
             "name": "imBack",
             "text": "Green",
             "type": "button",
             "value": "Green",
             "style": "default"
           }
         ],
         "fallback": "[no preview available]"
       }
     ]
   },
   "response_url": "https://hooks.slack.com/actions/REDACTED",
   "trigger_id": "REDACTED"
 },
 "ApiToken": "REDACTED"
}

If you look at the original_message, you can see that the text is blank. According to the Slack docs there should be a message property of the Block Actions Payload that contains the full state of the message.
Wasn't sure if this was a bug in the Bot Framework Service or the Bot Framework. We are using the Azure Bot Service for our bot. Thanks!

Ok, I think I figured out why. I have a middleware that sets the outgoing ChannelData.Text property to turnContext.Activity.Text and then sets turnContext.Activity.Text to null. The reason for this is we wanted the <@SlackUserId> formatting to work, which didn't work when setting turnContext.Activity.Text.
Any ideas how I can work around that?

Thank you for the report, @haacked
It sounds like you're saying you no longer think there's a bug, but you're encountering a problem based on your own middleware. What is the problem, and what are you trying to do? Can you post screenshots, links, etc.?

@v-kydela Yeah. The above code is the repro. The only thing its missing is I also have middleware that does the following (pseudocode).
public class SlackMiddleware : IMiddleware
{
    public async Task OnTurnAsync(
        ITurnContext turnContext,
        NextDelegate next,
        CancellationToken cancellationToken = new CancellationToken())
    {
        turnContext.OnSendActivities(async (_, activities, nextSend) =>
        {
            foreach (var activity in activities)
            {
                var channelId = activity.ChannelId ?? string.Empty;
                if (channelId is "slack")
                {
                    activity.ChannelData = new SlackOutgoingChannelData
                    {
                        Text = activity.Text
                    };
                    activity.Text = null;
                }
            }

            // run full pipeline
            return await nextSend().ConfigureAwait(false);
        });

        // process bot logic
        await next(cancellationToken).ConfigureAwait(false);
    }
}

Even though I set the Activity.Text to null, I expected that when the user clicked the button, all the info Bot Framework needs to populate the original message would be there. Does that make sense?

@haacked - There's still a lot of missing information about your problem and it sounds like you don't know how to get us on the same page as you. Maybe I can ask some guiding questions that will help.
Your middleware is taking the activity text and putting it in the activity channel data instead. The channel data has the same effect on Slack as the text would because the Slack connector uses the activity's channel data to populate the Slack message in the same way that it would use the activity's text if it was there. Therefore, the text you're putting in channel data ends up getting rendered in Slack. Is that correct?
I'm not understanding why you're doing this. You say:

The reason for this is we wanted the <@SlackUserId> formatting to work, which didn't work when setting turnContext.Activity.Text.

What does that mean? Can you elaborate and post screenshots?
What happens if you populate both the channel data and the text? Does that serve the purpose you're trying to serve?
Have you tried using the TextFormat property?
What specific text are you expecting to populate the original message? Can you post a screenshot of a message with that text and the buttons that aren't returning the text?
Slack makes it easy to see where one message ends and the next begins because the messages become highlighted when you mouse over them. Have you confirmed that the text you're expecting to be included in the original message is actually part of the same message as the buttons? Can you show that in a screenshot of the message where you're highlighting it with your mouse?
Also, it sounds like you're saying you expect your hero cards to be rendered using blocks, but blocks are a newer Slack schema that replaces an old one. Are you sure your buttons are rendered in blocks?

I'm not understanding why you're doing this. You say:

I misspoke. The reason we're using the channel data for the Text is because we want to support Slack stye markdown in our responses. We only do this for the Slack channel. For example, two differences are:
Slack code: `code`
Bot Framework code: \`code\`
Slack newline: \n
Bot Framework newline: \n\n

What happens if you populate both the channel data and the text? Does that serve the purpose you're trying to serve?

No, if the Text property is set on Activity AND it's set on ChannelData, they both are sent to the response. This is not the behavior I expected. Is that by design?

@haacked - The behavior of the connector services is somewhat complicated, but I presume that's by design. Thank you for the information so far. Do you think you might be able to answer the rest of my questions? I need to have a good idea of what's happening in order to help

The behavior of the connector services is somewhat complicated, but I presume that's by design.

Ah, that might explain it then. If that's by design, can you help me understand why? I feel like my mental model of ChannelData must be incorrect. It is surprising to me that if both the IMessageActivity.Text AND ChannelData.Text are set, that I get two messages.

I need to have a good idea of what's happening in order to help

Sure! I set up a simpler example.
Here's my bot code.
public class MyBot : ActivityHandler
{
    protected override async Task OnMessageActivityAsync(
        ITurnContext<IMessageActivity> turnContext,
        CancellationToken cancellationToken)
    {
        var activity = turnContext.Activity;
        if (activity.Text.EndsWith("test", StringComparison.InvariantCultureIgnoreCase))
        {
            var heroCard = new HeroCard
            {
                Buttons = new List<CardAction>
                {
                    new(ActionTypes.ImBack)
                    {
                        Title = "Cup 1",
                        DisplayText = "You chose Cup1",
                        Value = "cup1"
                    },
                    new(ActionTypes.ImBack)
                    {
                        Title = "Cup 2",
                        DisplayText = "You chose Cup2",
                        Value = "cup2"
                    }
                }
            };
            var response = MessageFactory.Text("Choose wisely");
            response.Attachments.Add(heroCard.ToAttachment());
            await turnContext.SendActivityAsync(response, cancellationToken);
            return;
        }

        // Handle user click
        var original = turnContext.Activity.ChannelData.Payload.original_message.text;
        await turnContext.SendActivityAsync(MessageFactory.Text($"Original Message was: {original}"), cancellationToken);
    }
}

Test Case 1
I don't have any middleware set up in this example.
And here's a screenshot of interacting with it in Slack.

As you can see, everything works fine. I click the button and I'm able to get the original message from the ChannelData Payload.
Test Case 2
Ok, now I'll set up the same middleware I posted above where I set IMessageActivity.Text to null because I'm using the ChannelData.Text to send a message to slack instead.

As you can see, when I click the button, I expected to be able to retrieve the original message, but I got nothing.
It seems to me that something got lost into the translation when posting the message to Slack. The reason I expected the original message to be there is even though I set IMessageActivity.Text to null, I did set the text of the message in the ChannelData. And I know that Slack is getting that message. So I expected that when slack responded to the event, the original message would be populated just fine. But since it's not, I'm guessing that Azure Bot Service is doing something in between.
Does this all make sense now?

@haacked

Ah, that might explain it then. If that's by design, can you help me understand why? I feel like my mental model of ChannelData must be incorrect. It is surprising to me that if both the IMessageActivity.Text AND ChannelData.Text are set, that I get two messages.

Think of it like this. Suppose IMessageActivity.Text and ChannelData.Text contain two different values. If the Slack connector was only supposed to display one of them as a message, how would it know which one to display?

Does this all make sense now?

It generally makes sense, but there's still some important information I need in order to diagnose the problem. It was good of you to provide screenshots, but they don't show you highlighting the messages with the mouse like I asked so I can't tell where the break between messages is. However, I think I can detect a very slight difference in the vertical space between "Choose wisely" and the buttons, so I suspect that means my hunch about them being separate messages is correct.
When I said "I need to have a good idea of what's happening in order to help," that was directly referring to my need for you to answer my questions. Are you able to see the questions in this comment? https://github.com/microsoft/BotFramework-Services/issues/299#issuecomment-840098796
Would you be more comfortable if I asked one question at a time?

Think of it like this. Suppose IMessageActivity.Text and ChannelData.Text contain two different values. If the Slack connector was only supposed to display one of them as a message, how would it know which one to display?

Well my original mental model was that the ChannelData represented the final form of the JSON that would get posted to the Slack API in order to send a message. So if both were set, ChannelData would win.  But now I can see my mental model is incorrect. It looks like they are effectively two different messages sent to Slack. And that matches up with your hunch:

so I suspect that means my hunch about them being separate messages is correct.

I think this also explains the behavior I'm getting. Since the buttons are part of an attachment set on IMessageActivity, but the text is set on ChannelData, they are sent as two different messages. So there's no way a click on the button could have the original message.
Thanks for your help in this! I'll close it unless you think my conclusion is incorrect. 😄


Support also Androzic

Also the mapping app Androzic is very useful (especially when you have OziExplorer maps).
It would be nice, if c:geo could support it.

Androzic is registered for com.google.android.radar.SHOW_RADAR, so use "Navigate --> Radar" in c:geo.

Good hint, thanks!

Btw. seems to be a nice app, will try it in the future. :)