text:
Unable to discriminate union type because of "Property does not exist"

TypeScript Version:  typescript@3.2.0-dev.20181025

Search Terms: union narrowing discriminate missing property field
Code
class Foo
{
    private foo: string;
}

class Bar
{
    private bar: number;
}

function fn(baz: { foo: Foo; bar: string; } | { foo: Bar; })
{
    if (typeof baz.bar != 'undefined')
    {
        testFoo(baz.foo);
    }
}

function testFoo(foo: Foo)
{
}

Expected behavior:
No Error. I can call testFoo(baz.foo) since the union type is properly narrowed.
Actual behavior:
Property 'bar' does not exist on type 'Baz'.
Argument of type 'Foo | Bar' is not assignable to parameter of type 'Foo'.
Type 'Bar' is not assignable to type 'Foo'.
Property 'foo' is missing in type 'Bar'.
Playground Link: https://www.typescriptlang.org/play/index.html#src=class Foo
{
    private foo%3A string%3B
}

class Bar
{
    private bar%3A number%3B
}

function fn(baz%3A { foo%3A Foo%3B bar%3A string%3B } | { foo%3A Bar%3B })
{
    if (typeof baz.bar !%3D 'undefined')
    {
        testFoo(baz.foo)%3B
    }
}

function testFoo(foo%3A Foo)
{
}
Related Issues: I've looked around but found none.
Although, in general, I do understand this should not work, I think it would help greatly if we had a way to discriminate on properties that are only in some of the members of a union.
One of the solutions could be to type properties, that are missing in some of the union members as prop?: void, or prop?: never, or prop?: undefined, or whatever makes sense in the type system.

Although, in general, I do understand this should not work, I think it would help greatly if we had a way to discriminate on properties that are only in some of the members of a union.

This should work
function fn(baz: { foo: Foo; bar: string; } | { foo: Bar; })
{
    if ("bar" in baz)
    {
        testFoo(baz.foo);
    }
}

With this PR #27695 you can also do this:
function fn(baz: { foo: Foo; bar: string; } | { foo: Bar; bar: undefined })
{
    if (baz.bar !== 'undefined')
    {
        testFoo(baz.foo);
    }
}

@jack-williams Your suggestion works. Thank you!
I'll keep this issue open as I think it should be documented and/or we could have better syntax for it... but I might be wrong. I'd like a member of TS team to have a look and provide a definitive decision on that if you don't mind...

BTW, there's a good reason this:
function fn(baz: { foo: Foo; bar: string; } | { foo: Bar; })
{
    if (typeof baz.bar != 'undefined')
    {
        testFoo(baz.foo);
    }
}

doesn't work - consider this call:
fn({bar: 12, foo: new Bar()});

that's a valid call (assignable to the second union member), and is why even if you were to check that bar wasn't undefined in the input, you might still not have a Foo for foo. The in operator is intentionally a little unsound here, but we figured that its usage was infrequent enough that if you use it you really wanted it to act like this.

Indeed. I haven't thought of this case.
I guess it would impossible to implement it in a completely sound way.
Thanks for your answer!

BTW, there's a good reason this:
function fn(baz: { foo: Foo; bar: string; } | { foo: Bar; })
{
    if (typeof baz.bar != 'undefined')
    {
        testFoo(baz.foo);
    }
}

doesn't work - consider this call:
fn({bar: 12, foo: new Bar()});

that's a valid call (assignable to the second union member), and is why even if you were to check that bar wasn't undefined in the input, you might still not have a Foo for foo. The in operator is intentionally a little unsound here, but we figured that its usage was infrequent enough that if you use it you really wanted it to act like this.

Hi, I strolled by this thread randomly and I am immediately baffled as to why fn({bar:12, foo: new Bar()}) should be a valid call?
Let me play the role of a verbose compiler:

value {bar: 12, foo: new Bar()} cannot be assigned to {foo: Foo, bar: string}, because bar is 12, 12 is not string.
value {bar: 12, foo: new Bar()} cannot be assigned to {foo: Bar} either, because it contains an extra bit bar: 12, and TS2322 says: "object literal may only specify known properties". field bar is unknown to type {foo: Bar}.
So I will throw an error, I can either reject it because 12 is not a string, or I can reject it with TS2322.

And I tested it, indeed fn({bar:12, foo: new Bar()}) is not valid call, as tsc complains that number 12 is not a string. (tested for strictNullCheck = true and false)
But then here comes the weird part: fn({bar:"lol", foo: new Bar()}) is a valid call! This surprises me, as it still doesn't fit either type, for the same reasons the verbose compiler rejected it earlier. Let me role play again:

value {bar:"lol", foo: new Bar()} cannot be assigned to {foo: Foo, bar: string}, because foo is new Bar(), which is not a Foo.
value {bar:"lol", foo: new Bar()} cannot be assigned to {foo: Bar} either, because it contains an extra bit bar: 12, and TS2322, blah blah.
I should raise an error saying either new Bar() cannot be assigned to Foo, or TS2322.

But since reality doesn't agree with me, it must be I'm understanding union types wrong, or maybe TS has a bug. Do you know what's happening here?

BTW, there's a good reason this:
function fn(baz: { foo: Foo; bar: string; } | { foo: Bar; })
{
    if (typeof baz.bar != 'undefined')
    {
        testFoo(baz.foo);
    }
}

doesn't work - consider this call:
fn({bar: 12, foo: new Bar()});

that's a valid call (assignable to the second union member), and is why even if you were to check that bar wasn't undefined in the input, you might still not have a Foo for foo. The in operator is intentionally a little unsound here, but we figured that its usage was infrequent enough that if you use it you really wanted it to act like this.

Hi, I strolled by this thread randomly and I am immediately baffled as to why fn({bar:12, foo: new Bar()}) should be a valid call?
Let me play the role of a verbose compiler:

value {bar: 12, foo: new Bar()} cannot be assigned to {foo: Foo, bar: string}, because bar is 12, 12 is not string.
value {bar: 12, foo: new Bar()} cannot be assigned to {foo: Bar} either, because it contains an extra bit bar: 12, and TS2322 says: "object literal may only specify known properties". field bar is unknown to type {foo: Bar}.
So I will throw an error, I can either reject it because 12 is not a string, or I can reject it with TS2322.

And I tested it, indeed fn({bar:12, foo: new Bar()}) is not valid call, as tsc complains that number 12 is not a string. (tested for strictNullCheck = true and false)
But then here comes the weird part: fn({bar:"lol", foo: new Bar()}) is a valid call! This surprises me, as it still doesn't fit either type, for the same reasons the verbose compiler rejected it earlier. Let me role play again:

value {bar:"lol", foo: new Bar()} cannot be assigned to {foo: Foo, bar: string}, because foo is new Bar(), which is not a Foo.
value {bar:"lol", foo: new Bar()} cannot be assigned to {foo: Bar} either, because it contains an extra bit bar: 12, and TS2322, blah blah.
I should raise an error saying either new Bar() cannot be assigned to Foo, or TS2322.

But since reality doesn't agree with me, it must be I'm understanding union types wrong, or maybe TS has a bug. Do you know what's happening here?

value {bar:"lol", foo: new Bar()} cannot be assigned to {foo: Bar} either, because it contains an extra field bar: 12, and there is a TS rule against that.

This is the wrong bit -- extra fields are allowed when there is some matching property in the target across any union member.

value {bar:"lol", foo: new Bar()} cannot be assigned to {foo: Bar} either, because it contains an extra field bar: 12, and there is a TS rule against that.

This is the wrong bit -- extra fields are allowed when there is some matching property in the target across any union member.

This is the wrong bit -- extra fields are allowed when there is some matching property in the target across any union member.

Yeah, about that.
That was my initial feeling so I did some more testing which ended up contradicting this.
declare function id_or_name(input: {id:number; name:"joe"}|{name:string})
id_or_name({id:3, name:"alex"})  // Argument of type '{ id: number; name: string; }' is not assignable to parameter of type '{ id: number; name: "joe"; } | { name: string; }'. Object literal may only specify known properties, and 'id' does not exist in type '{ name: string; }'.ts(2345)

Somehow this time it doesn't work again. I notice though that if instead of having name:<primitive type/literal type> in the parameter, you have name: <ObjectType>, then it behaves like you describe again.
function id_or_name(input: {id:number; name:Date}|{name:string}): void {return}
id_or_name({id:3, name:"alex"})  // no problem

This is the wrong bit -- extra fields are allowed when there is some matching property in the target across any union member.

Yeah, about that.
That was my initial feeling so I did some more testing which ended up contradicting this.
declare function id_or_name(input: {id:number; name:"joe"}|{name:string})
id_or_name({id:3, name:"alex"})  // Argument of type '{ id: number; name: string; }' is not assignable to parameter of type '{ id: number; name: "joe"; } | { name: string; }'. Object literal may only specify known properties, and 'id' does not exist in type '{ name: string; }'.ts(2345)

Somehow this time it doesn't work again. I notice though that if instead of having name:<primitive type/literal type> in the parameter, you have name: <ObjectType>, then it behaves like you describe again.
function id_or_name(input: {id:number; name:Date}|{name:string}): void {return}
id_or_name({id:3, name:"alex"})  // no problem

authors: RyanCavanaugh jack-williams lemoinem nuts-n-bits weswigham


text:
Mixin with abstract class constraint forces abstract memeber implementation

TypeScript Version:  3.4.0-dev.20190130

Search Terms: abstract mixin
When using a mixin function, if the constraint to the constructor returns an abstract class (T extends new (...a: any[])=> AbBase) we are forced to implement the abstract members in the mixin class. This seems strange since if the passed in class satisfies the constructor signature constraint it will not be an abstract class, as abstract classes do not have a callable constructor.
Code
abstract class AbBase {
    abstract m(): void ;
}
function mixin<T extends new (...a: any[])=> AbBase>(c: T) {
    let a = new c(); // We can instantiate
    return class extends c { // but when deriving the class we need to redefine abstract members

    }
}

mixin(AbBase) //Argument of type 'typeof AbBase' is not assignable to parameter of type 'new (...a: any[]) => AbBase' as expected, no chance c would be abstract

Expected behavior:
The mixin function  should compile without error
Actual behavior:
The compiler raises an error on the class defined in the mixin function : Non-abstract class expression does not implement inherited abstract member 'm' from class 'AbBase'.
Playground Link: Link
Related Issues: None
Motivating SO question

@rbuckton FYI, I found this #26617 related issue. This issue seems more general. If we have a constructor signature returning an abstract class the compiler will complain we have to implement all members even though we can never assign an abstract class to such a constructor signature

abstract class Base {
  abstract m(): void
}

let ctor: new () => Base;
ctor = Base /// error we can't assign an abstract class to this
ctor = class extends Base { // we can only assign a non-abstract class
  m() { }
}

// Non-abstract class 'Derived' does not implement inherited abstract member 'm' from class 'Base'
// Why is this an error at all ? The constructor returns an instance of an abstract class but can never be an abstract class
class Derived extends ctor {
}

IMO the true issue is there is no way to represent an abstract class constructor. Ideally I would like to be able to tell the compiler that  I have an abstract class constructor and it should enforce implementation of abstract members (something like new abstract () => Base). If my constructor signature is just new () => Base then this is not the constructor of an abstract  class and I should not have to implement the methods
let ctor: new abstract () => Base; // new syntax
ctor = Base /// this is allowed now

class Derived extends ctor {  // errors expected here we don't implement base members
}

This can make mixins a PITA!
It would be really useful: yesterday I wanted to make a mixin, and constrain it to classes of a certain base type (which happens to be marked as abstract). It doesn't make sense for the mixin to implement all of the abstract members. The mixin just wants to enforce a constraint, and to even possibly call abstract methods, under the assumption that the user of the mixin (and of the abstract base class) will be implementing the members.
Here's a playground example.
Is there some workaround, some way to remove the abstracted (and abstracted in some type functions to make it clean), so that in the mixin the constrained base class does not appear to be abstract?
I've tried some tricks like
type NonAbstractBase = Pick<Base, keyof Base>

and then using NonAbstractBase for the constraint type, but that has issues where it converts method types into property types, etc, and then that introduces other errors.
Another workaround is to just not use the abstract keyword, and do stuff like throw new Error('Method not implemented') in the base class, delegating the check to runtime. But doing this makes it easy to make mixins.
It would be super sweet to be able to do this in TypeScript, just like in plain JS.
(Relating to abstract support for mixins, there's also https://github.com/microsoft/TypeScript/issues/32122)

@dragomirtitian I think the solution to this is actually simple. The abstract keyword simply needs to be usable anywhere besides at the top level.
We should be able to stick the abstract keyword in front of the class that a mixin returns, just in this example: playground.
Secondly, regarding your point, I don't think we necessarily need a way to specify an abstract new() => ... constructor. I think the type check should allow something like new(...args: any[]) => SomeAbstractClass to be a valid type (because, it is representing a totally valid JS object), but type type checker should forbid the use of new on callsites using new with that type.
So, this could be the case:
abstract class SomeAbstractClass {/* ... */}

const Ctor = new(...args: any[]) => SomeAbstractClass // NO ERROR

new Ctor // ERROR, can't call `new` on abstract class.

If the type checker did all of my above comment, then:

it makes sense: we shouldn't be able to instantiate an abstract class. However, the reference is a totally valid constructor. In JS, we can call it. In TS, it can simply prevent calling it.
abstract class {} syntax is already perfectly valid existing syntax. It would make perfect sense to be able to return an abstract class from a class factory function.

I believe this would be the most intuitive way to solve the issue without introducing new syntax.

@trusktr I don't necessarily agree that calling new on new(...args: any[]) => SomeAbstractClass should issue an error. The constructor signature does not mean that the constructor returns that exact type, but rather any derived type. This is very useful where you want to have a collection of constructors all returning a common base type.
interface X { m(): void; }

class A implements X { m() { console.log("A");} }
class B implements X { m() { console.log("B");} }
class C implements X { m() { console.log("C");} }

let o : Array<new () => X> = [A, B, C];

let r = Math.round(Math.random() * 2);
new o[r]().m();

A constructor signature can return any type, be it an interface,  a union whatever else, and no assumptions are made about the constructor itself based on the return type. It is only in the special case of inheritance where the fact that a constructor returns an abstract class that the assumption is made that this means the constructor itself is of an abstract class.

The constructor signature does not mean that the constructor returns that exact type

Ah, that's true. (I was confused at first why I couldn't use new(...args: any[]) => any for the constraint of a mixin function, but then I realized that it needs to be new(...args: any[]) => {} to specify the minimum)
I was trying to constrain a mixin Base class to something like C extends typeof AbstractClass, but that doesn't work. Why doesn't that work? Isn't typeof AbstractClass a constructor? It seems like it would be intuitive to write it that way.

It is only in the special case of inheritance where the fact that a constructor returns an abstract class that the assumption is made that this means the constructor itself is of an abstract class.

This is important. I figured how to get rid of the issue with abstract class being returned by just not returning it all in the same statement (same applies to decorators):
abstract class SomeBaseClass {
    abstract base(): boolean
}

function CoolMixin<
  C extends new(...args: any[]) => SomeBaseClass,
  T extends InstanceType<C>
>(Base: C) {
  abstract class Cool extends Base {
    cool() {
      console.log("cool");
    }
  };

  return Cool
}

class Bar extends CoolMixin(SomeBaseClass) { // ERROR
  bar() {
    console.log("bar");
  }
}

playground
Seems like that's just a bug.
But notice the error, that an abstract class isn't assignable to the new (...) => ... type.
If we avoid modifying syntax, can we just treat the abstract class as a subset of the new()=>{} type? I mean, after all, the reference is, literally, a constructor in JavaScript, and TypeScript wishes to depict JavaScript.

What I mean is, in my previous example, at a conceptual level, how is SomeBaseClass (despite being abstract) not a new(...args: any[]) => SomeBaseClass? It's otherwise valid JavaScript.

Hmmmm, maybe abstract interface is needed instead?:
abstract interface Type {
  nonAbstractMethod(): boolean
  abstract method(): number
}

abstract interface TypeCtor {
  new (): Type
}

or something

And, to tie it all together, typeof AbstractClass would effectively return something like that abstract interface TypeCtor interface, and it could be used in the constraint of a mixin.

An idea: why not have abstractedness be automatically inherited by a subclass if the subclass does not implement all the abstract features, and then throw a type error like "Can not instantiate abstract class" at the sites where the constructor is called?
Yes, this would make the type error once-removed from the place where the issue is, but maybe abstractedness inheritance would actually be a feature.
Example:
abstract Foo {
  abstract foo(): number
}

// this class is abstract, because it didn't implement foo():
class Bar extends Foo {
  bar = 123
}

const b = new Bar() // Error, can not instantiate Bar because it is an abstract class

Or, maybe, just simply allow abstract class {} in expression sites.
It seems simple to allow abstract classes to work in expressions. I haven't made changes to TypeScript source before. Would this be easy? It seems like a useful addition.

Hmmmm, maybe we need something like abstract interface:
abstract interface Type {
  nonAbstractMethod(): boolean
  abstract method(): number
}

abstract interface TypeCtor {
  new (): Type
}

or something

@trusktr Actually, if you add //@ts-ignore to the abstract methods of an interface, you'll found that TypeScript already support abstract interface members.
interface Mixin
{
    //@ts-ignore
    abstract abstractMethod(): void;
}

interface MixinStatic<T extends Class>
{
    new(): InstanceType<T> & Mixin;
}

TypeScript Playground

@JasonHK I would not recommend using @ts-ignore on  anything as part of a recommended workflow. If you have to suppress an error to get the behavior you want it is by definition not sported , even if it by accident works as you are essentially relying on undocumented behavior .

@JasonHK  Huh! Neat hack! I'll have to take that for a spin. I'm more interested in my consumers getting the desired features than in me avoiding mistakes. At least it isn't me fully reverting all the way back to plain JavaScript.

Is there an update on this? I am also failing to apply a mixin to an abstract base class.

I have a few mixins in my Angular project.  Here is one I am currently using.  Don't know if this helps, but here goes:
import { Injector } from '@angular/core';
import { AbstractBaseService } from './abstract-base.service';
import { UserService } from '../../authorization/services/user.service';
import { User } from '../../authorization/entities/user';
export abstract class AbstractBaseService implements OnInit {
private _injector: Injector = null;
protected get injector(): Injector {
    return this._injector;
}

constructor(injector: Injector) {
    this._injector = injector;
}

public ngOnInit() {
	//You may do a few things here before forwarding to
	//subclass via initializeAll
    $this.initializeAll();
}
/**
 * initializeAll is post ngOnInit, allowing ngOnInit to do brief initialization
 * within the AbstractBaseService while allowing the subclass to do whatever it needs.
 **/
protected abstract initializeAll(): void;

}
// Mixins setup....................................................................
type Constructor = new (...properties: any[]) => T;
type Mixin<R extends (...properties: any[]) => any> = InstanceType<ReturnType>;
export const WithUserInjection = <T extends Constructor>(base: T) => {
class UserInjectedService extends base {
private _userService: UserService = null;
	protected get userService(): UserService {
		return this._userService;
	}
	protected get user(): User {
		return this._userService.user;
	}

	constructor(...properties: any[]) {
		super(properties[0] as Injector);
		this._userService = this.injector.get(UserService);
	}
	protected initializeAll(): void {
		throw new Error("Method not implemented.");
	}
}

return UserInjectedService;

}
export type WithUserInjection = Mixin;

This is supported as of TypeScript 4.2! See the release notes on abstract constructor signatures.
abstract class AbBase {
    abstract m(): void;
}

function mixin<T extends abstract new (...args: any[]) => any>(c: T) {
    abstract class Mixin extends c {
        mixinMethod() {
            return 42;
        }
    };
    return Mixin;
}

class Example extends mixin(AbBase) {
    m() {
        console.log(this.mixinMethod());
    }
}

Try it on the Playground.

When I'm looking at this I'm thinking that this should be possibe.
abstract class FooAbstract {
    abstract bar(): {};

}

let autoInititatedFoos: FooAbstract[] = new Array<FooAbstract>;

function autoInitiate<T extends new (...args: any[])=>FooAbstract>(cons...

Playground Link
Because something like this isn't possible with the abstract new approach.

source: gharchive/issue

authors: IslandWalker JasonHK Maikeio MattiasBuelens dragomirtitian joelrich trusktr

repo: microsoft/TypeScript

license_type: permissive

license_source: github-api


text:
Conditionally filter types from tuples at transpilation time.

Search Terms
tuple, filter, metaprogram
Suggestion
I'd like a better way to filter types from a tuple type (or indeed object type). Currently I can easily make a type not optional (with -?) or make one optional (?) but I can't conditionally remove a type element from a tuple to produce another tuple. Well actually I can, with this crazy metaprogram that uses up so much CPU that it isn't usable in the real world:
type NumberMap = {
  0: 1
  1: 2
  2: 3
  3: 4
  4: 5
  5: 6
  6: 7
  7: 8
  8: 9
  9: 10
  10: 11
  11: 12
  // up to twelve supported
  12: 12
}
￼
// prepending is relatively easy
type Prepend<H, T extends any[]> = ((h: H, ...t: T) => void) extends (
  ...l: infer L
) => void
  ? L
  : never
￼
// appending is possible but expensive and hard, must
// build lists in reverse and reverse the result when done
type Reverse<L extends any[], R extends any[] = []> = {
  0: R
  1: ((...l: L) => void) extends (h: infer H, ...t: infer T) => void
    ? Reverse<T, Prepend<H, R>>
    : never
}[L extends [any, ...any[]] ? 1 : 0]

type Equals<I extends number, L extends number> = I extends L ? 1 : 0

type FilterBoolean<T, R extends any[]> = T extends boolean ? R : Prepend<T, R>

type FilterBooleansNext<
  I extends keyof NumberMap,
  T extends any[],
  R extends any[]
> = T extends []
  ? R
  : {
      0: FilterBooleansNext<NumberMap[I], T, FilterBoolean<T[I], R>>
      1: R
    }[Equals<I, T['length']>]

// append is hard/expensive, so keep prepending and reverse the result
export type FilterBooleans<T extends any[]> = Reverse<
  FilterBooleansNext<0, T, []>
>

Use Cases
I am writing a parser library where you can build parsers by composing operators (each operator being a higher order function). When composing a parser using the sequence operator, the return type of the sequence should be a tuple of the return types of each operator the sequence is composed from. However the return types of "predicate" operators should be excluded from the tuple return type since the predicate operators don't parse any data, they only match or fail to match.
Examples
// need something better than `excluded` here I guess, using it as a placeholder.
type FilterBooleans<T> = { [K in keyof T]: T[K] extends boolean ? excluded : T[K] };

type TupleWithoutBooleans = FilterBooleans<[string, boolean, number]>;
type RecordWithoutBooleans = FilterBooleans<{ s: string, b: boolean, n: number }>;

Checklist
My suggestion meets these guidelines:

[x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
[x] This wouldn't change the runtime behavior of existing JavaScript code
[x] This could be implemented without emitting different JS based on the types of the expressions
[x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
[x] This feature would agree with the rest of TypeScript's Design Goals.

What does "remove a type from an object" mean?

I'm guessing you want this
type Step1<T> = { [K in keyof T]: T[K] extends boolean ? never : K }[keyof T];
type FilterBooleans<T> = { [K in Step1<T>]: T[K] }

// { s: string, n: number }
type RecordWithoutBooleans = FilterBooleans<{ s: string, b: boolean, n: number }>;

The corresponding thing for tuples is kind of conceptually weird since it implies some kind of splicing operation?

@RyanCavanaugh Thanks for the suggestion, I see that works for non-tuples. Cool! But if I run:
FilterBooleans<[string, boolean, Date, boolean]>;

I get the type:
type TupleWithoutBooleans {
  4: undefined;
  0: string;
  2: Date;
}

I need it for my parser generator though, so I can build a parser from component functions.
const parseRule = parseSequence(parseRuleName(), notPredicate(parseConstant("<"))

The notPredicate return type shouldn't be in the tuple type returned by the parseRule function.

@RyanCavanaugh This is labelled "Waiting for feedback" but I'm not sure what feedback you'd like, could you let me know?
BTW in typescript 4.1 I can do this:
type NoBoolean<K, T> = T extends boolean ? never : K

type FilterBooleans<T> = {
  [K in keyof T as NoBoolean<K, T[K]>]: T[K]
}

type Filtered = FilterBooleans<[string, boolean, number, boolean]>

Here type Filtered looks like the tuple I want, only it's a record, with a key 0 of string, a key 2 of number, a length of the constant 4 and all the functions from the array prototype. It would be great if there was a tuple equivalent of what you can already now do with records. Maybe something like:
type FilterBooleans<T> = [
  [K in keyof T as NoBoolean<K, T[K]>]: T[K]
];

(i.e. the same as above but with the { and } changed to [ and ]). Without this, my parser combinator framework needs a lot of manual help from the user.

Closing in favour of https://github.com/microsoft/TypeScript/issues/42122

This is labelled "Waiting for feedback" but I'm not sure what feedback you'd like, could you let me know?

@insidewhy: The Awaiting More Feedback label has this description:

This means we'd like to hear from more people who would be helped by this feature

authors: MartinJohns RyanCavanaugh insidewhy


text:
Exclude<string, "foo"> is not working

TypeScript Version:  3.8.3 or earlier
Search Terms: Exclude, Conditional Types
Code
type Foo = Exclude<string, "bar">;

// this should cause an error.
const baz: Foo = "bar";

Expected behavior:
"bar" is not assignable to baz.
Actual behavior:
"bar" is assignable to baz without any errors.
Playground Link: https://www.typescriptlang.org/play/#code/FAFwngDgpgBAYgewTAvDAogDwMYBsCuAJlADwDOIATgJYB2A5gDQwBEARgIaUsB8A3MGDYEtCjE4AvAFzwkqVp24ChIsglxQAdLgT0AFJICUAoA

Not the most elegant, but here is a work-around.
https://www.typescriptlang.org/play/?ssl=4&ssc=1&pln=5&pc=1#code/C4TwDgpgBAQghgOwRAJlAvFARAIzgJywG4AoUSKAMQHtqMoBRADwGMAbAVxQgB4BnYPgCWCAOYAaWImQoAfKRItqCAVDwAvKAC4qtergLEoAemNU4Qtn110h1uFAHCxJEgDMOCFsCHKo1AGseABUoCCZgCAQUaycRUVkACgA3HVCAMihE0PDI6Ot4JFQoAH5sGABBADkqhgARLB0AbwBfAEo2qCaSKCh8CGAOfAQoZNIW1yUVYDU4dQB9Nws2ekDEg0JO03NLPkVlVQ15wNWA9YRqebxNkzMAYQALCBYAviA

This is limitation of Exclude. Basically it works when you "filter" unions, but string is not a union.
What you are lookin is Negated types: #29317 and comment about your use case https://github.com/microsoft/TypeScript/pull/29317#issuecomment-452987604

Thank you for comments!
I guess it means that, in the type system of typescript, string type is not a 'representative' or 'set' of any valid strings.
I thought string means the set of any of it including 'foo', 'bar' or any others of string.

Yeah, unfortunately we're not wired up to "cut holes" out of infinitely large domains  of types, and it appears that adding that assumption to the type system would make it incredibly painful to use.
Regarding

https://www.typescriptlang.org/play/?ssl=4&ssc=1&pln=5&pc=1#code/C4TwDgpgBAQghgOwRAJlAvFARAIzgJywG4AoUSKAMQHtqMoBRADwGMAbAVxQgB4BnYPgCWCAOYAaWImQoAfKRItqCAVDwAvKAC4qtergLEoAemNU4Qtn110h1uFAHCxJEgDMOCFsCHKo1AGseABUoCCZgCAQUaycRUVkACgA3HVCAMihE0PDI6Ot4JFQoAH5sGABBADkqhgARLB0AbwBfAEo2qCaSKCh8CGAOfAQoZNIW1yUVYDU4dQB9Nws2ekDEg0JO03NLPkVlVQ15wNWA9YRqebxNkzMAYQALCBYAviA

you might be able to get away with using never in place of BANNED

authors: DanielRosenwasser IllusionMH frodo821 stormpat


text:
[bug] [project-references] "tsc --build" fails to report non-existent module errors

TypeScript Version:  3.8.3
Search Terms:
"typescript build project references no error on non-existent module"
"typescript build project references no error on incorrect import"
"typescript build project references no error when module is not found"
Code
import "./file-that-does-not-exist" // No error!

Expected behavior:
There should be an error.
Actual behavior:
The next screenshot in VS Code show that if I try to go to the definition of the module, it can't find it (because it doesn't exist, and Webpack also says the same), yet the TypeScript build (tsc --build) does not report any error.

Is this related to imports that don't create any identifiers?
Playground Link:
I don't have a reproduction, only a private repo at the moment.
Related Issues:
Possibly related: https://github.com/microsoft/TypeScript/issues/38495

I'll just close this and re-open if/when I have a simple reproduction.


text:
Move to new file does not carry over global 'use strict'

Given a javascript source file that sets strict mode ('use strict'),
When using the Move to a new file refactoring to extract a function declaration,
Then the resulting function ends up in a non-strict file.
It is possible for this to change the program's behavior.

VSCode Version: 1.48.1
OS Version: Windows 10

Steps to Reproduce:

Given main.js:

'use strict'
const fs = require('fs')
function foo() { return this }
console.log(foo())

Running node main produces the output:

undefined

Extract foo using the Move to a new file refactoring.

This modifies main.js:
'use strict'
const fs = require('fs')
const { foo } = require("./foo")
console.log(foo())

and generates foo.js:
function foo() { return this; }
exports.foo = foo;

Now running node main produces the output:

Object [global] {
  global: [Circular],
  ....

Manually adding 'use strict' to foo.js restores the original behavior.

Do we need to suggest "Move to a new file" for directives?
[|"use strict";|] ?

function foo() {
    [|"use strict";|] ?
}

cc @DanielRosenwasser @RyanCavanaugh

No, the intent is that when declarations are moved to a new file, every prologue should be moved over as well.

Actually, I'm going to close this as a duplicate of #30478 because I already filed this issue.

Ouch, I can do PR to resolve the issue with the prologue directives, if, of course, this is acceptable.

Absolutely, that would be great!

authors: DanielRosenwasser a-tarasyuk spazmodius


text:
Error using indexed access types with mapped types

Bug Report
🔎 Search Terms
indexed access types, mapped types
🕗 Version & Regression Information

This changed between versions 4.6.4 and 4.7.0

⏯ Playground Link
v4.8.0-dev.20220525 ❌
v4.7.0-beta ❌
v4.6.4 ✅
v4.5.5 ❌
💻 Code
type Types = {
  first: { a1: true };
  second: { a2: true };
  third: { a3: true };
}

class Test {
  entries: { [T in keyof Types]?: Types[T][] }

  constructor() {
    this.entries = {};
  }

  addEntry<T extends keyof Types>(name: T, entry: Types[T]) {
    if (!this.entries[name]) {
      this.entries[name] = [];
    }

    this.entries[name]?.push(entry); // error
  }
}

🙁 Actual behavior
Got the following error:
Argument of type '{ a1: true; } | { a2: true; } | { a3: true; }' is not assignable to parameter of type '{ a1: true; } & { a2: true; } & { a3: true; }'.
  Type '{ a1: true; }' is not assignable to type '{ a1: true; } & { a2: true; } & { a3: true; }'.
    Property 'a2' is missing in type '{ a1: true; }' but required in type '{ a2: true; }'

🙂 Expected behavior
No error. Or maybe I missed something, and this was intentional.
Seems like it was fixed in https://github.com/microsoft/TypeScript/pull/47109 and broken in v4.7.

Looks like something's going on when the mapped type is optional.  This happened between 4.7.0-dev.20220302 and 4.7.0-dev.20220329.  It would definitely be nice if this didn't stay broken in 4.7.x for long.

Yeah, this is a bug. We're being a bit too conservative in the isMappedTypeGenericIndexedAccess function. It disallows any ? modifiers when really it should only disallow -?. Easy fix, I'll have a PR up soon.

authors: ahejlsberg irudoy jcalz


text:
Automatically deduce the parameter type in the callback function

Bug Report
Automatically deduce the parameter type in the callback function
🔎 Search Terms
callback, object deconstruction, type deduction
🕗 Version & Regression Information
Playground version V4.7.4
⏯ Playground Link
Typescriptlang Playground
code
type CallBack = (_: number) => number

function sqk({x}:{x:number}): Promise<number>;
function sqk({x,callback}:{x:number,callback:CallBack}): void;
function sqk({x,callback}:{x:number,callback?:CallBack}): Promise<number>|void  {
  if(callback){
   callback (x * x);
  }
  return Promise.resolve(x)
}

// ❌ here our callback will receive a number, but the `x` can‘t  be deduced
const cb = sqk({x:5, callback:function(x) {
  console.log(x);
  return x;
}});

// ✅
const promise = sqk({x:5}).then(x=>{console.log(x)})

🙁 Actual behavior
Callback will receive a number, but the  type of x can‘t  be deduced
🙂 Expected behavior
A possible solution is to remove the callback from the object as the second parameter，as follows：
type CallBack = (_: number) => number

function sqk(x:number): Promise<number>;
function sqk(x:number,callback:CallBack): void;
function sqk(x:number,callback?:CallBack): Promise<number>|void  {
  if(callback){
   callback (x * x);
  }
  return Promise.resolve(x*x)
}

// ✅
const cb = sqk(5,(x)=> {
  console.log(x);
  return x;
});

// ✅
const promise = sqk(5).then(x=>{console.log(x)})

But this doesn't answer my question, why the first solution doesn't work？is it a bug?

Overload resolution always picks the first overload that matches, so the second overload won't ever get picked. You need to reverse the order of them:
function sqk({x,callback}:{x:number,callback:CallBack}): void;
function sqk({x}:{x:number}): Promise<number>;

Thanks for your help, pointing out the key points, I think I need to read the docs more confidently, this question can be closed.

authors: RyanCavanaugh Sylvenas


text:
[Proposal] Typescript Overriding Type

Typescript Overriding the Type
🔍 Search Terms

typescript utility type override

✅ Viability Checklist
My suggestion meets these guidelines:

[x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
[x] This wouldn't change the runtime behavior of existing JavaScript code
[x] This could be implemented without emitting different JS based on the types of the expressions
[x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
[x] This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion
Sometimes we need to override the some property in same interface with another type; :wink:
📃 Motivating Example
playground
💻 Use Cases
We can have this type alias as Type Tools :
type Override<
	T,
	K extends Partial<{ [P in keyof T]: any }> | string,
> = K extends string
	? Omit<T, K> & { [P in keyof T]: T[P] | unknown }
	: Omit<T, keyof K> & K;

And, We have an interface alike below :
interface IUser {
    username: string;
    phone: string;
    // any else properties
}

Then, We need the same interface with some another type for username property
interface IEmployee extends IUser {
    username: [department: string, code: number]; // -> error
    tasks: Array<any>;
}

But If we use the Override type?
interface IEmployee extends Override<IUser, 'username'> {
    username: [department: string, code: number]; // -> work
    tasks: Array<any>;
}

Or This Syntax :
interface IEmplyee extends Override<IUser, { username: [department: string, code: number]; }> {
    tasks: Array<any>;
}

Or we have an ICustomer interface with same properties with IUser but for username property that should be given the number as the type
type ICustomer = Override<IUser, { username: number }>;

Also We can use alike below syntax :
interface ICustomer Override<IUser, { username: number }> {};

Work with Type Assignment :
// use-case
const employees: IEmployee = {
	username: ['any-string', 1234],
	tasks: [],
    phone: '09123456789'
};

// use-case
const customers: ICustomer = {
	username: 1234,
    phone: '09123456789'
};

Or any another example for this Overidde Utility Type, Thanks
Exactly this is just a Concept and with Week Example (take it easy :wink:)

You can already do extends Omit<T, 'prop'> so this type alias seems unnecessarily complicated (it has to do more than the bare minimum to even be useful as there's already a thing built-in that does its main job).

You can already do extends Omit<T, 'prop'> so this type alias seems unnecessarily complicated (it has to do more than the bare minimum to even be useful as there's already a thing built-in that does its main job).

Yes Exactly but not for accept interface as generic type to overriding, omit just accept the key of interfacebut thisOverrideType givekeyandinterface` also :wink:

This will be declined, since it's only for developer convenience, and not needed by the compiler to emit .d.ts files.

Hi @jcalz :wave:
Exactly :
Any fool can write code that a computer can understand. Good programmers write code that humans can understand

@DanielRosenwasser

or intersecting with a new property

Intersecting with a new property doesn't work the way interface/extends does though... For example
// this type came from a library, I need to replace foo: any
type A = {
  foo: any
}

type B = A & { foo: number }

type T = B['foo'] // I need this to be number, but it's still any

interface/extends does get the desired behavior, but...if something is easier to do with interfaces, I wish TS would engineer a way to do it just as easily with type literals.  Type literals are just way more convenient because they can be used inline.  For example, let's say I have
type Props = {
  b: A
}

And I want to constrain the type of foo.b to be number.  Do I want to break out a separate interface declaration just to do that?  No, that would be a hassle.  I would just:
type Props = {
  b: Omit<A, 'foo'> & { foo: number },
}

As such when there's more than one property to override, the Omit pattern becomes a pain because of the duplicated property names, and I find myself thinking I should declare an Override type that does what OP proposes.  But then, I think, this should really just be a builtin.

what if it's be a reusable keyword? :thinking:
// basic
interface One {
	property: number;
}

// replace
interface Two extends One {
	override property: string ;
}

// union mode
interface Three extends One {
	extends property: string;
}

// cases
assertTypeEqual<One, { property: number }>;
assertTypeEqual<Two, { property: string }>;
assertTypeEqual<Three, { property: number | string }>;

authors: fatcerberus jedwards1211 mikoloism


text:
TypeScript does not catch type that does not match complex union

Bug Report

🔎 Search Terms
Complex union, should not compile
🕗 Version & Regression Information
This is the behaviour in every version I tried, and I reviewed the FAQ for entries about unions.
⏯ Playground Link
Playground link with relevant code
💻 Code

type ContrivedType =
  | {
      foo: "BAR" | "BAZ";
    }
  | {
      foo: "QUX";
      qux: "qux";
    }
  | {
      foo: "BAR" | "BAZ";
      baz: "baz";
    };

// This should not compile, but it does!
const contrivedExample: ContrivedType = {
  foo: "BAR",
  qux: "qux",
};

🙁 Actual behavior
It compiles.
🙂 Expected behavior
It should not compile.

Duplicate of #51873. From a type system perspective it's perfectly fine, because your object matches the first type of the union. Objects are not sealed, they can have additional properties. People often don't realize it because of the "excess property checks", which was called more of a linter feature.

Thanks for the swift reply @MartinJohns!

your object matches the first type of the union.

I am not sure if I fully understand what the TypeScript compiler is doing this case. For example, if instead of this union I just try the first case, it catches the error just fine:
// This does not compile, as expected
const hmmm: { foo: "BAR" | "BAZ" } = {
  foo: "BAR",
  qux: "qux",
};

Similarly, it also catches the error if I remove the third object in the union, like so:
type ContrivedType =
  | {
      foo: "BAR" | "BAZ";
    }
  | {
      foo: "QUX";
      qux: "qux";
    };

// Now this fails to compile, as expected
const contrivedExample: ContrivedType = {
  foo: "BAR",
  qux: "qux"
};

I fear I might be misunderstanding something, but this feels inconsistent. :thinking: I'll take some time to read the duplicate issue, maybe it'll help me understand better what's going on. .

For example, if instead of this union I just try the first case, it catches the error just fine:

This is the "excess property check" that I mentioned. This only applies to object literals. This example compiles just fine:
const hmmm = { foo: "BAR", qux: "qux" } as const;
const demo: { foo: "BAR" | "BAZ" } = hmmm;

Similarly, it also catches the error if I remove the third object in the union, like so:

Excess property checks does not for work for unions with an overlapping discriminator property. See the issue I linked earlier: #51873. In your first example the discriminator foo with the type "BAR" overlaps, by removing the third union case you don't have it overlap anymore.

Thanks again for the explaination @MartinJohns! Sorry I took to so long to respond, it took me some time to get up to speed with all the concepts like discriminated unions. You're absolutely right of course: this is a duplicate, so I will close this issue.

authors: MartinJohns jlek


text:
Don't slice whitespace in jsdoc parser unless needed

It's only needed when there's an indentation relative to the margin, which is rare and usually doesn't last for the entire comment text. The common case is to skip the whitespace.
Works on https://github.com/microsoft/TypeScript/issues/52959, based on a suggestion from @DanielRosenwasser in #53081

@typescript-bot perf test this

@typescript-bot perf test this

source: gharchive/pull-request


text:
[Release] Milestone M155

Mac

1176	Platform native notifications PR_2
1193	Mac ProjFS: Only hydrate/expand when deleting due to rename
1202	Platform native notifications PR_3
1215	Remove Placeholder after calling PreDelete
1250	Mac: Switch on the UTF8 Tests
1257	Mac: Bash Functional Test Hang
1285	Installer reliability
1318	Mac build scripts: consume git installer pkg directly
1319	Don't change version number of dev builds
1322	Script to generate GVFS.Installer.Mac nuspec
1340	PrjFSKextLogDaemon: Don't log every time a dropped kext message is detected

Cross-Platform

1267	Add logging to clone/mount paths
1287	use repository relative paths in DiffTreeResult.TargetPath
1301	simplify Git functional tests of case-sensitive file paths
1320	Making max pipe length platform-dependant
1375	Remove all TODO(POSIX) and TODO(Mac) comments

Git

1283	Incremental commit graph
1300	Update Git to include status deserialize fix
1342	Update Git to include tracing updates
1382	Update Git to include more tracing updates

Upgrade

1224	ProductUpgrader: platform specific upgrade directories
1225	Upgrader - platform specific directory creation
1228	Upgrader: copy entire application directory
1230	Upgrader: add command install action
1234	Upgrader: implement cross platform functionality
1268	NuGetUpgrader: fix issue with upgrader using interop services
1270	VFSForGit Installer non-relocatable
1284	Enable mac upgrade MVP
1297	Upgrader: NuGet Upgrader should use GitHub endpoint for notifications
1312	Use the new signing certificate
1381	Upgrade: Fix test flakiness around upgrade reminders

FastFetch

1291	use correct checkout thread maximum in FastFetch

Polish

1241	Update heartbeats for folder placeholders and file hydration
1257	Mac: Bash Functional Test Hang
1263	Log Folder Placeholders Removed
1281	PrefetchStep: don't send post-fetch request if no new packs
1282	Remove requirement to run --no-renames
1317	Setup.iss: Update GitHub URL
1328	Move Enlistment Directory For Functional tests to ~/GVFS.FT
1380	GitProcess: Catch InvalidOperationException when setting priority class

Backports from M153

1259	Update Git to v2.22.0
1276	POSIX: Switch to Process.Start for launching GVFS.Mount
1278	Fix performance regression in LibGit2RepoInvoker

/azp run GitHub VFSForGit Large Repo Build
/azp run GitHub GitHub VFSForGit Large Repo Perf Tests

Large Repo Perf run succeeded with expected results. All difference was within error bounds.

authors: derrickstolee jrbriggs

repo: microsoft/VFSForGit

license: MIT


text:
Fix commit-graph expiration

Wow, this was really not working as expected.
See microsoft/git#255 for how broken the --expire-time argument was.
Fix this by using the fixed argument and passing a datetime instead of an offset by seconds. This will provide a longer window for old commit-graph files, but apparently we've been leaving turd files around for a long time without anyone noticing.

/azp run PR - Windows - Build and Unit Test

/azp run PR - Windows - Functional Tests

/azp run PR - Windows - Functional Tests (Sparse Mode)

/azp run PR - Windows - Extra


text:
Feature/Request for Git Events (Branch changed, Git Pull, etc)

Hello, are there any plans to supporting git events in the API?
Example: subscribe to whenever a git branch has changed, git pull, etc.
This would enable several neat extensions such as: Auto stash/restore when pulling a repo with pending git changes, auto apply DB migrations, etc

Thanks for your suggestion! I've created a suggestion ticket to track this so folks can vote on it: https://developercommunity.visualstudio.com/t/VisualStudioExtensibility---FeatureReq/10680306. This isn't on our short-term roadmap, but if we get substantial votes, we can reconsider.

authors: luislhg tinaschrepfer

repo: microsoft/VSExtensibility


text:
WslRegisterDistribution failed with error: 0xc03a0014

Windows Version
Microsoft Windows [Versión 10.0.22621.1702]
WSL Version
1.2.5.0
Are you using WSL 1 or WSL 2?

[x] WSL 2
[ ] WSL 1

Kernel Version
No response
Distro Version
No response
Other Software
No response
Repro Steps
wsl --install ubuntu
Expected Behavior
Install and run ubuntu in WSL
Actual Behavior
Install but return a error for provider.
Installing, this may take a few minutes... WslRegisterDistribution failed with error: 0xc03a0014 Error: 0xc03a0014 No se encontr¾ un proveedor de compatibilidad con disco virtual para el archivo especificado.
also i use (Get-WindowsOptionalFeature -online | Where-Object { $_.FeatureName -match "hyper" -or $_.FeatureName -match "linux"})
FeatureName : HypervisorPlatform
State       : Enabled

FeatureName : Microsoft-Windows-Subsystem-Linux
State       : Enabled

FeatureName : Microsoft-Hyper-V-All
State       : Enabled

FeatureName : Microsoft-Hyper-V
State       : Enabled

FeatureName : Microsoft-Hyper-V-Tools-All
State       : Enabled

FeatureName : Microsoft-Hyper-V-Management-PowerShell
State       : Enabled

FeatureName : Microsoft-Hyper-V-Hypervisor
State       : Enabled

FeatureName : Microsoft-Hyper-V-Services
State       : Enabled

FeatureName : Microsoft-Hyper-V-Management-Clients
State       : Enabled

Note: i used WSL in the past.. for not reason this error happen i try reinstall WSL but the error still show.
Diagnostic Logs
No response

same

same

Same here:
This Ubuntu issue seems to result because a previously working WSL has failed to mount the required virtual machine.
The 'WSL fails to start' error is described in this unresolved issue:
9178: https://github.com/microsoft/WSL/issues/9178
MY SETUP:
Windows 10 Enterprise 10.0.19045
on ASRock B450 Pro4 motherboard
with Hyper-V and 'Virtual Machine Platform' turned on
using: WSL 1.2.5.0_x64 Kernel 5.15.90.1
with "ubuntu-18.04" or "ubuntu 20.04"
PROBLEM: in PowerShell as Admin, I get:
PS C:\WINDOWS\system32> wsl
Failed to attach disk 'C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.2.5.0_x64__8wekyb3d8bbwe\system.vhd' to WSL2: The request is not supported.
Error code: Wsl/Service/CreateInstance/CreateVm/MountVhd/0x80070032
PS C:\WINDOWS\system32>
<<< also >>>
PS C:\WINDOWS\system32> bash
Failed to attach disk 'C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.2.5.0_x64__8wekyb3d8bbwe\system.vhd' to WSL2: The request is not supported.
Error code: Bash/Service/CreateInstance/CreateVm/MountVhd/0x80070032
PS C:\WINDOWS\system32>
<<< running download for Ubuntu instance yields >>>
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0xc03a0014
Error: 0xc03a0014 A virtual disk support provider for the specified file was not found.
Press any key to continue...

https://github.com/microsoft/WSL/issues/10555#issuecomment-1937980344

authors: Doc94 bjoseph-aya joe-mit karimMogh neokofg

repo: microsoft/WSL


text:
PyTorch Can't transfer anything to GPU

Environment
Windows build number: Version 2004 (Build 20150.1000)
Your Distribution version: Ubuntu 20.04
Whether the issue is on WSL 2 and/or WSL 1: WSL2
Linux Kernel: 4.19.121-microsoft-standard
Python: 3.5.4
PyTorch: 1.2
Geforce Driver: 455.41

Steps to reproduce
import torch

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
tensor = torch.zeros(1, 1, 10)
tensor.to(device)

torch.cuda.is_available() returns true.
Expected behavior
PyTorch should transfer the tensor to the GPU.
Actual behavior
It crashes with
CUDA error: unknown error

I find its ok;
i use ubuntu 20.04
pip install torch==1.5.1 torchvision==0.6.1
i am not install cuda just torch 1.5.1 and torchvision
(test) lab@pc_yqh:~$ python
Python 3.6.10 |Anaconda, Inc.| (default, May  8 2020, 02:54:21)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
.zeros(1, 1, 10)

When I update my torch and pytorch version with
pip3.5 install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html
the code runs without an error but doesn't work either.
import torch

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
tensor = torch.rand(1, 1, 10)
tensor.to(device)

tensor_two = tensor + tensor

runs and torch.cuda.is_available() still returns true. But if I inspect tensor_two at the end the device attribute of it is device(type="cpu").
And I want to work with PyTorch Version 1.2, not 1.5.1.

When I update my torch and pytorch version with
pip3.5 install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html
the code runs without an error but doesn't work either.
import torch

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
tensor = torch.rand(1, 1, 10)
tensor.to(device)

tensor_two = tensor + tensor

runs and torch.cuda.is_available() still returns true. But if I inspect tensor_two at the end the device attribute of it is device(type="cpu").
And I want to work with PyTorch Version 1.2, not 1.5.1.

>>> import torch
>>> device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
>>> device
device(type='cuda', index=0)
>>> tensor = torch.rand(1, 1, 10)
>>> tensor
tensor([[[0.0096, 0.1139, 0.7168, 0.8277, 0.4454, 0.5753, 0.7148, 0.4055,
          0.8267, 0.7882]]])
>>> tensor.to(device)
tensor([[[0.0096, 0.1139, 0.7168, 0.8277, 0.4454, 0.5753, 0.7148, 0.4055,
          0.8267, 0.7882]]], device='cuda:0')
>>> tensor
tensor([[[0.0096, 0.1139, 0.7168, 0.8277, 0.4454, 0.5753, 0.7148, 0.4055,
          0.8267, 0.7882]]])
>>> tensor = tensor.to(device)
>>> tensor
tensor([[[0.0096, 0.1139, 0.7168, 0.8277, 0.4454, 0.5753, 0.7148, 0.4055,
          0.8267, 0.7882]]], device='cuda:0')
>>> tensor_two = tensor + tensor
>>> tensor_two
tensor([[[0.0192, 0.2279, 1.4336, 1.6553, 0.8908, 1.1505, 1.4295, 0.8111,
          1.6534, 1.5763]]], device='cuda:0')

any news on this issue?

This is now working with
PyTorch: 1.5.1 (CUDA 10.1)
Python: 3.5.9

instead of my previous setup
PyTorch: 1.2 (CUDA 10)
Python: 3.5.4

I would still consider it as a problem though since I would like to work with PyTorch 1.2 since it is the version that we use in our workplace.
Maybe this helps you @keesschollaart81

authors: Erik-Sovereign devsnets sailyung


text:
Error code: Wsl/Service/E_UNEXPECTED

Version
Microsoft Windows [Versión 10.0.19045.2486]
WSL Version

[X] WSL 2
[ ] WSL 1

Kernel Version
5.15.79.1
Distro Version
Ubuntu 22.04
Other Software
No response
Repro Steps
steps taken until I got the error, in a fresh OS installation

Activate systemd
sudo nano /etc/wsl.conf
[boot] systemd=true

wsl.exe –shutdown

Install webmin
sudo nano /etc/apt/sources.list → deb https://download.webmin.com/download/repository sarge contrib
wget https://download.webmin.com/jcameron-key.asc
cat jcameron-key.asc | gpg --dearmor >/etc/apt/trusted.gpg.d/jcameron-key.gpg
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install webmin

install webinoly (lemp)
wget -qO weby qrok.es/wy && sudo bash weby -clean
sudo stack -php-ver=8.1
sudo stack -mysql-ver=10.6
sudo stack -lemp

So far so good, all services work properly.
Expected Behavior
When closing the console window where the linux operating system is open, the WSL is expected to stop all services in the background and turn off the virtual machine.
Actual Behavior
When I start the application again I get the following error:
Fatal Error
Error code: Wsl/Service/E_UNEXPECTED
press any key to continue
and then the window closes.
Diagnostic Logs
No response

/logs

this just happened to me after shutting down my ubuntu distro and then rebooting (after installing a few packages from the ubuntu-desktop bundle)

it somehow automagically revived itself?
installed the rest of the bundle (when i say bundle i mean the packages listed among "the following NEW packages will be installed" thing). working amazing so far

WslLogs-2023-04-14_07-19-36.zip
For me WSL runs great initially. I notice this issue if I come back to work after a big gap. Once I hit the error, wsl --shutdown is useful.
Linux home-pc 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Distributor ID: Ubuntu
Description:    Ubuntu 22.10
Release:        22.10
Codename:       kinetic

I am running the following: snaps, microk8s and I use VSCode plugin for WSL.

same error

same error:
Error code: Wsl/Service/E_UNEXPECTED
please.

@Taco0220, If you need to restore the WSL "machine" (to recover files, etc.), see if this approach can help you: https://stackoverflow.com/a/76354545/1493870
It's not the solution to this issue. Only a way to get back the files inside the WSL.

I've tried a lot of things, but nothing worked。

This just happened to me

Get it frequently lately. Much confusion. I feel like it started once I:

updated to latest
enabled options="metadata"
enabled dbus

# Check if DBus is running, if not, launch it
if ! pgrep -x "dbus-launch" > /dev/null; then
    eval `dbus-launch --sh-syntax`
#    echo "DBus session started."
fi


text:
WinAppDriver hangs when findElement

Now , I am trying to operate Windows .Net form Application by WinAppDriver.
I can create session with remote connection, and I can get some properties such as winHandle,winTitle.
DesiredCapabilities appCap = new DesiredCapabilities();
appCap.setCapability("platformName", "Windows");
appCap.setCapability("deviceName", "WindowsPC");
appCap.setCapability("appTopLevelWindow", {targetWinHandle});
WindowsDriver driver = new WindowsDriver(new URL("http://{my ip}:4723/wd/hub"), appCap);

but when I try to findElementByXPath, the session hangs and no response.
I had to shutdown session on cmd console to restart.
driver.findElementByXPath("//*");

# WinAppDriver cmd console

==========================================
POST /wd/hub/session/xxxxxxxxxxxxxxxxxxxxxx/element HTTP/1.1
Accept-Encoding: gzip
Connection: Keep-Alive
Content-Length: 50
Content-Type: application/json; charset=utf-8
Host: x.x.x.x:4723
User-Agent: selenium/3.141.59 (java windows)

{
  "using": "xpath",
  "value": "\u002f\u002f*"
}
... no response ...

I want to know why it hangs, but it may be difficult to solve because the information I've showed is less.
So I wish that WinAppDriver will output some exeption or error log on such case.
Environment

master pc

Windows10 Pro
AdoptOpenJDK 8.x
Appium java_client 7.2.0
Selenium 3.141.59

remote pc

Windows10 IoT OS
WinAppDriver.exe 1.2
Target Application: Windows .Net Form Application

@NathanZook , @licanhua
Sorry it was bad example.
No matter xPath is,(If I tried to using another xPath such as "//Window[@Name="{my_app window_name"]") , then WinAppDriver hangs and no response.
And I've tried Windows Calculator sample, and it worked fine.

It's hard to tell if it's the app or winappdriver problem. winappdriver connected to app by accessibility interface, so it makes WinAppDriver has no response if app itself has no response.

You can check the cpu usage to see who is busy
use visual studio or other debugger. Stack trace and thread information may help you to understand what the process is doing.
other functions(not xpath) which may dump all the elements, for example get page source.
use inspect.exe, narrator, or appium-desktop to inspect the application when problem happens.

authors: licanhua shift-morikawa

repo: microsoft/WinAppDriver


text:
Discussion: Simplify deployment for packaged app that not in store

Discussion: Simplify deployment for packaged app that not in store

Currently, to deploy a UWP app that you don't want to publish to ms store for whatever reason, you need to deliver the certificate to the end-user, the end-user needs to enable developer mode, install the certificate then install the actual app. or use the PowerShell script, it's a bit more complicate for the end-user, and it will deliver multiple files to the end-user.
I think it would be better to have just one install package file and just "click -> install -> run" without dealing with the certificate and other things. Just like Android's APK file, it does obtain a signature but the end-user will never notice that.

Yes please. That pain when client says "just send me the .exe" and you have to explain why is it more complicated than it was 10 years ago...

Do you have more information on the certificate you are using?  Anything that we can verify authenticity does not require extra steps.  Adding a certificate is usually only required for enterprises when they are using their own root, but usually deploy in mass to their devices.  If you are using a self signed certificate that offers not authenticity and is basically equivalent to not signing code.
If the issue is the type of signing certificate we plan on launching a preview of the Azure Trust Service this summer.  The goal is to reduce the friction in signing flows for developers.  The first part of this presentation covers the plans for code signing. MSIX Build

starting in the May 2020 update (2004) the sideloading setting has been removed and apps can be installed from any source similar to other installer techs

Great to hear that:)
Just clarify that it's not the problem of the certificate, it's the installation process that makes the end-user a little bit confused, they usually ask why can't just open a single installation file and click install then everything is good to go, just like what they used to.
For example, currently, when you create an app package for a UWP app with sideloading, you need a certificate, after build finish, there will be a folder that contains the app with files like *.msixbundle, Install.ps1, *.cer and some subfolder. You will need to deliver the whole folder to the end-user and tell them to run Install.ps1 to install the app. Or you will need to tell the user how to install *.cer file first like this
This is much more complex than the "traditional" way like the installation process of vscode, you just have to download a single file, open it, install it, and everything is good to go.

you are using a self signed certificate that offers not authenticity and is basically equivalent to not signing code. If the issue is the type of signing certificate we plan on launching a preview of the Azure Trust Service this summer. The goal is to reduce the friction in signing flows for developers.

@jvintzel  it was supposed to be launched last summer right?    open source developers are in need of this very service. can we now expect an answer please     since it's already past 1 year?

it's a bit more complicate for the end-user

It's not a "bit" more complicated. This is an absolute showstopper for many deployment scenarios and invalidates an entire family of new MS tech that would otherwise be appropriate if it didn't essentially force MSIX.

Can you elaborate on why you think this is a showstopper? I don't see any difference here from traditional software rollout.

It seems a lot of friction here revolves around the distribution and installation of self signed packages. This is not normal, and not something you should be doing beyond development/test.

This is not normal, and not something you should be doing beyond development/test.

Making a regular MSI without any of the ceremony is normal, works out of the box, and doesn't require buying (management is happy) or juggling certificates (devs are happy).
I understand the reasoning behind all this signature business, but it doesn't work in practice. It's a showstopper because the friction is too much and makes ignoring msix the straightforward choice. Don't use it and everything works again out of the box for everyone. Why bother with this new thing with no immediate and clear benefits but plenty of drawbacks?

I understand the reasoning behind all this signature business, but it doesn't work in practice.

do tell what works then ? making everything free ? you aware that "FrEe SoFtWaRe FoUnDaTiOn Cult "   also runs on sucking donations/money right ?
Advice : I understand the frustration but making everything free is not the way the world works. Nothing is free is in this world. Instead  You could've asked to make certificates prices affordable for indie devs.

Don't use it and everything works again out of the box for everyone.

as you seem to figure it out, keep using MSI then.

Why bother with this new thing

why bothering here in the first place ? to vent ?

I understand the reasoning behind all this signature business, but it doesn't work in practice.

do tell what works then ? making everything free ? you aware that "FrEe SoFtWaRe FoUnDaTiOn Cult "   also runs on sucking donations/money right ?
Advice : I understand the frustration but making everything free is not the way the world works. Nothing is free is in this world. Instead  You could've asked to make certificates prices affordable for indie devs.

Don't use it and everything works again out of the box for everyone.

as you seem to figure it out, keep using MSI then.

Why bother with this new thing

why bothering here in the first place ? to vent ?

that is why now some people must suffer where they didn't use to?

authors: Tlaster ghost000000000 ihavefoxdie jvintzel lcsondes mcosmin22 riverar tesar-tech

repo: microsoft/WindowsAppSDK


text:
Remove unneeded references to VisualStudio.CoreUtility

The build is unable to find this, but there was never impact of not finding it since it was not used.
Removing it.

/azp run


text:
[Core] Sanitize filename before using it as docker image tag. Fix #1069

Why are these changes needed?
Sanitize filename before using it as docker image tag.
In addition, removing the skips for Mac OS X platforms -- they all passed.
Related issue number
Fix #1069
Checks

[ ] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally.
[x] I've added tests (if relevant) corresponding to the changes introduced in this PR.
[x] I've made sure all auto checks have passed.

Codecov Report
Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (b26e659) 30.81% compared to head (accbe2b) 18.67%.
Report is 2 commits behind head on main.

Files
Patch %
Lines

autogen/code_utils.py
14.28%
6 Missing :warning:

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1127       +/-   ##
===========================================
- Coverage   30.81%   18.67%   -12.15%
===========================================
  Files          30       30
  Lines        4037     4043        +6
  Branches      915      966       +51
===========================================
- Hits         1244      755      -489
- Misses       2714     3204      +490
- Partials       79       84        +5

Flag
Coverage Δ

unittests
18.67% <14.28%> (-12.10%)
:arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Yes. I will use this library for sanitizing filename generated by LLM. Although for the purpose of generating a docker tag name, the library doesn't support it -- a post-processing of the filename is still required to make it a valid docker tag name.

This library is useful for sanitizing filename generated by LLM. Although for the purpose of generating a docker tag name, the library doesn't support it -- a post-processing of the filename is still required to make it a valid docker tag name. So for the purpose of fixing #1069 we still need the custom function.
Perhaps we can have a separate PR for sanitizing filename generated by LLM?

Ah, fair enough! It's just that all that custom sanitization code made me uncomfortable. I've made too many errors in this area in the past, and prefer pre-built libraries for this kind of thing.

I agree random UUID tag is probably a good idea. Although there is a readability component to it (https://docs.docker.com/engine/reference/commandline/tag/), and the only semantically relevant information about the container in the function is the code and the filename which are both generated by the LLM.

I agree random UUID tag is probably a good idea. Although there is a readability component to it (https://docs.docker.com/engine/reference/commandline/tag/), and the only semantically relevant information about the container in the function is the code and the filename which are both generated by the LLM.

Is there a risk that to allowing the llm to name the containers? Will they reuse the same names ever? Is it ok if they do? What is the tradeoff with the other two extremes: Using a fixed tag name hat is shared by all calls (e.g., "python:autogen") vs a UUID to guarantee uniqueness?

Probably a combination of two? e.g., python:_<llm_generated_description>

Is there a risk to allowing the llm to name the containers? Will they reuse the same names ever? Is it ok if they do?

I think the risk of allowing llm to name the container is at the level of potentially reusing another container that is currently being used by other purpose. It would be okay if it is using a container created earlier for the same or previous iteration of the code.
To address this we would need to have a concept of a coding session with a container created for the purpose of this session only. Currently the filename is used to identify the session. If the caller does not provide a filename then a hash generated from the code itself is used as a filename. So currently exactly same code may means container reuse.

What is the tradeoff with the other two extremes: Using a fixed tag name that is shared by all calls (e.g., "python:autogen") vs a UUID to guarantee uniqueness?

We probably don't want to use the same container for all because each coding session may have different libraries installed and there will be issue with dependency management. We probably want to have uniquely identifiable sessions so iterations of the generated code gets to share the same environment.
My feeling is that since this PR does not change the expected behavior of the current code, we can design the new code execution logic in a separate PR.

@BeibinLi  do you want to review this?

authors: afourney codecov-commenter ekzhu

repo: microsoft/autogen


text:
List

Any chance to provide a List sample taking advantage of azure-devops-ui?
I can only find a Pivot which implements office-ui-fabric-react.

You can find samples under the List and Table components on the components site:
https://developer.microsoft.com/en-us/azure-devops/components/list
https://developer.microsoft.com/en-us/azure-devops/components/table

authors: chris-to-pher nkirchem

repo: microsoft/azure-devops-extension-sample


text:
Ability to specify staging directory in configuration

Plugin name and version
azure-functions-maven-plugin:1.16.0
Plugin configuration in your pom.xml
<plugin>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-functions-maven-plugin</artifactId>
    <version>1.16.0</version>
    <configuration>
        <appName>${functionAppName}</appName>
        <resourceGroup>${resourceGroup}</resourceGroup>
        <appServicePlanName>${appServicePlanName}</appServicePlanName>
        <runtime>
            <os>linux</os>
            <javaVersion>8</javaVersion>
        </runtime>
        <auth>
            <type>service_principal</type>
            <serverId>azure-auth</serverId>
        </auth>
    </configuration>
    <executions>
        <execution>
            <id>package-functions</id>
            <goals>
                <goal>package</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Expected behavior
Sometimes names of the function app and staging directory are different and it would be good to have ability to specify staging directory manually in plugin configuration
Actual behavior
Currently it's not possible to specify staging directory in azure-functions-maven-plugin configuration

@jshaptic Thanks a lot for your feedback, I agree that staging directory should be customized, I've added this item to the back log.
Besides, currently maven toolkit will use <appName> in plugin configuration as the name of staging folder, could you please help share the project that app name diffs from staging folder name if possible?

I don't think I will be able to find some open-source project with such needs, but I can share some details regarding my current project. We have a multi-environment setup, where each environment has its own function instance  and each one has diffferent name, e.g. function-dev, function-stage, function-prod etc.
So, it would be really good to have ability to build only once, but deploy many times to different environments - in this case staging folder will have environment-agnostic name, whereas app name will have environment prefix.

I see this has been open for a year now. Any idea when this issue will be worked on? We have the exact same need as the OP.

authors: Flanker32 jshaptic marcia-schulman

repo: microsoft/azure-maven-plugins


text:
create environment agent with tags, in unattended mode

When registering an Environment agent on a VM interactively it prompts me to add tags. Is there a way to add tags even when running --unattended, without going through the UI?
.\config.cmd --environment --environmentname "01 - Development" --agent $env:COMPUTERNAME --runasservice --work '_work' --url '<redacted>' --projectname '<Redacted>' --auth PAT --token <redacted> --unattended

solved it, you can use --addvirtualmachineresourcetags --virtualmachineresourcetags "<tag>"

repo: microsoft/azure-pipelines-agent


text:
Hosted Agent- Azure Container Instances -gtVersion 2.172.0

Having issue with software on Hosted Agent?
I configure the hosted container instance agent and get an error
"##[error]No agent found in pool aci-agent which satisfies the specified demands: Agent.Version -gtVersion 2.172.0"
Agent Platform:
Azure DevOps Services

Hi @cheahengteong there seems to be demand in your pipeline - agent version should be greater than 2.172.0.
You would probably need to update your agent, or at least make sure that auto-update is enabled for your agent pool.

Hi @cheahengteong do you have any updates?

@anatolybolshakov yes

@cheahengteong is this issue still actual for you? Have the steps above helped you to resolve it?

You can refer to the https://medium.com/@cloudlabs01/running-azure-self-hosted-agent-in-azure-container-instance-aci-ad1fa338d769

@ceteongvanness thanks! As I see there are instructions to set up self-hosted agent with azure container instance, although the error here seems to be related to demand required by some pipeline (agent version should be greater than 2.172.0). Seems like it was either configured with version less than 2.172.0, or there is some other possible reason).
@cheahengteong I'm closing this at the moment due to inactivity - please let us know if you have any questions.
For Azure DevOps related questions - you can also open a ticket on https://developercommunity.visualstudio.com/search?space=21 to get support


text:
Added parameter to setResourcePath to add posibility to disable warnings thrown

Added parameter to setResourcePath method to add posibility to disable warnings thrown
Related issue:
#274

Can you add the same pr targeting the releases/3.x branch?

Can you add the same pr targeting the releases/3.x branch? https://github.com/microsoft/azure-pipelines-task-lib/tree/releases/3.x

I opened it here. Could you please take a look. Thank you!

Thanks!

Published!

authors: damccorm egor-bryzgalov

repo: microsoft/azure-pipelines-task-lib


text:
DownloadPipelineArtifact task patterns not working

Required Information
Entering this information will route you directly to the right team and expedite traction.
Question, Bug, or Feature?
Type: Bug
Enter Task Name: Download Pipeline Artifacts task
list here (V# not needed):
https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/DownloadPipelineArtifact (V2)
Environment

Server - Azure Pipelines or TFS on-premises?

Server - Azure Pipelines, acc:schwarzit, project:kaufland.bads-ai, repo:KAP.airflow

Agent - Hosted or Private:

Private, RHEL 7.7 (Maipo), vsts-agent-linux-x64-2.174.1
Issue Description
Expect matching pattern to match file correctly. Minimatch pattern matches 0 files.
Start downloading artifact - airflow.cfg_sometext-scratched_chd
Minimatch patterns: [*_chd]
Filtered 0 files from the Minimatch filters supplied.
Downloaded 0.0 MB out of 0.0 MB (100%).
Patterns tested:
*chd*
*chd
*_chd
All return 0 matches.

Possible root cause is the '.' in the filename
https://github.com/isaacs/minimatch/issues/82
To be tested

repo: microsoft/azure-pipelines-tasks


text:
Deployment Error by CustomDeployment from Template to Azure

I am unfortunately getting the following error when using the one-click deployment to azure:
{"code":"DeploymentFailed","target":"/subscriptions/XXX/resourceGroups/XXXX/providers/Microsoft.Resources/deployments/resources-5stymuvr2bba2","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"BadRequest","target":"/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Resources/deployments/resources-5stymuvr2bba2","message":"{\r\n  "code": "BadRequest",\r\n  "message": "The character 'F' at index 0 is not allowed in the DatabaseAccount name\r\nActivityId: 6a63308f-d2c3-49ea-a9df-fd1c369b7938, Microsoft.Azure.Documents.Common/2.14.0"\r\n}"}]}

the errors is related to the cosmosdb but I cant see what caused it:

The character 'F' at index 0 is not allowed in the DatabaseAccount name

What deployment name are you using?

solved was caused by capital letter

authors: RobertHoegner Xtrah

repo: microsoft/azurechatgpt


text:
There is a vulnerability in node-fetch 2.5.7,upgrade recommended

https://github.com/microsoft/azuredatastudio/blob/536628603e6df2a343f3bdf05df99e6aa0dfb706/extensions/microsoft-authentication/yarn.lock#L13-L14
CVE-2020-15168
Recommended upgrade version：2.6.1

This is a typing file for a dev dependency.  I don't think the CVE applies in this case.  We'll update it in a future build though.

authors: QiAnXinCodeSafe kburtram

repo: microsoft/azuredatastudio


text:
Formatting not kept on copy+paste

Issue Type: Bug
Format of field not kept when copying and pasting into other applications, ie Visual Studio, Excel, Sublime text.
How field actually looks (hovering over field in results pane):

How it looks after pasting into IDE:

Azure Data Studio version: azuredatastudio 1.32.0 (4a45ba7cf20dd4129f1a08e5e776dfb33e3d1d1e, 2021-08-16T18:08:28.086Z)
OS version: Windows_NT x64 10.0.19043

System Info

Item
Value

CPUs
Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 x 2592)

GPU Status
2d_canvas: enabledgpu_compositing: enabledmultiple_raster_threads: enabled_onoop_rasterization: enabledopengl: enabled_onrasterization: enabledskia_renderer: enabled_onvideo_decode: enabledvulkan: disabled_offwebgl: enabledwebgl2: enabled

Load (avg)
undefined

Memory (System)
15.86GB (6.23GB free)

Process Argv

Screen Reader
no

VM
0%

Extensions: none

@fsmythe I just tried this with long html content and unchecking the configuration worked for me. have you tried to reopen the query editor after making the configuration change?

The issue has been fixed.

Hi, sorry to bring up an old thread/issue but still persists. See more detailed screenshots below. Setting was unticked then Azure Data Studio completely restarted. No effect.
Hover over field in azure data studio, note the carriage return symbols:

After copy and pasting into visual studio code:

Showing setting is unticked (tried ticked too no difference)

Same field copy and pasted from SQL Management Studio 19 (no issues):

Let me know if you need anything else.

The issue has been fixed.

Issue not fixed for me, see above, should I open a new issue or can you re-open this one for me? Thanks

authors: alanrenmsft fsmythe


text:
Declarative table component fixes

Fixes https://github.com/microsoft/azuredatastudio/issues/14048
We now :

Don't add duplicate items to container components. If an item is attempted to be added that already exists then we just skip it (and log a warning since that should not be a normal case)
Clear out the declarative table component when setting new data values

please fix the unit test failure

Pull Request Test Coverage Report for Build 742392656

33 of 92 (35.87%)  changed or added relevant lines in 1 file are covered.
9 unchanged lines in 1 file lost coverage.
Overall coverage increased (+0.006%) to 43.554%

Changes Missing Coverage
Covered Lines
Changed/Added Lines
%

src/sql/workbench/api/common/extHostModelView.ts
33
92
35.87%

Files with Coverage Reduction
New Missed Lines
%

src/sql/workbench/api/common/extHostModelView.ts
9
35.28%

Totals

Change from base Build 734125201:
0.006%

Covered Lines:
26187

Relevant Lines:
54951

💛  - Coveralls

authors: Charles-Gagnon alanrenmsft coveralls


text:
Synapse query editor dropdown fix

This is a substitute for https://github.com/microsoft/azuredatastudio/pull/16485
It fixes https://github.com/microsoft/azuredatastudio/issues/16501
Seems the issue with fetching serverInfo from STS was fixed with Aasim's recent fix. I was able to remove the instance name based off of that.

@abist Some of the tests are still failing. Can you please fix them?

@aasimkhan30 That's the reason it's not merged yet. These tests don't seem to fail locally but only on ADO. You can see my previous commits.

Pull Request Test Coverage Report for Build 1124927796

6 of 11 (54.55%)  changed or added relevant lines in 2 files are covered.
458 unchanged lines in 11 files lost coverage.
Overall coverage decreased (-0.3%) to 41.307%

Changes Missing Coverage
Covered Lines
Changed/Added Lines
%

src/sql/workbench/contrib/query/browser/queryActions.ts
4
9
44.44%

Files with Coverage Reduction
New Missed Lines
%

extensions/data-workspace/src/common/workspaceTreeDataProvider.ts
3
77.22%

src/sql/workbench/browser/modal/modal.ts
14
60.71%

src/sql/workbench/contrib/query/browser/queryActions.ts
16
48.17%

extensions/sql-database-projects/src/tools/netcoreTool.ts
21
43.79%

extensions/data-workspace/src/services/workspaceService.ts
31
64.64%

src/sql/workbench/contrib/notebook/browser/notebookViews/notebookViewsActions.ts
42
30.6%

src/sql/workbench/contrib/notebook/browser/notebookViews/insertCellsModal.ts
43
22.43%

src/sql/workbench/contrib/notebook/browser/notebookViews/notebookViews.component.ts
54
6.98%

extensions/schema-compare/src/schemaCompareMainWindow.ts
60
75.74%

src/sql/workbench/services/connection/browser/connectionManagementService.ts
78
75.02%

Totals

Change from base Build 1117984469:
-0.3%

Covered Lines:
26184

Relevant Lines:
57500

💛  - Coveralls

authors: aasimkhan30 abist coveralls


text:
Remove extra click in python smoke test

This click is not needed since the New Python Installation option is selected by default.

I don't think this specific step was breaking anything, it just timed out while waiting for this element. At first I thought about increasing the timeout but since the step is not necessary anyways, it's better to remove it.
I'll be adding screenshots in a separate PR.

Pull Request Test Coverage Report for Build 1140965257

0 of 0   changed or added relevant lines in 0 files are covered.
No unchanged relevant lines lost coverage.
Overall coverage decreased (-0.002%) to 41.357%

Totals

Change from base Build 1140867446:
-0.002%

Covered Lines:
26439

Relevant Lines:
57961

💛  - Coveralls


text:
[SQL Migration] Implement URI handler

In this PR, we implement an URI handler for the sql-migration extension, which supports one path (/start) which allows the user to launch the migration wizard directly without having to manually navigate to the "Migrate to Azure SQL" button in the UI. Additionally, with optional parameters, the user can provide an arbitrary list of databases (or specify that they'd like all databases) which will be pre-selected on step 1 of the migration wizard.
Sample URIs:

azuredatastudio://Microsoft.sql-migration/start

Launches the migration wizard, as if the user were to manually click the "Migrate to Azure SQL" button in the extension UI

azuredatastudio://Microsoft.sql-migration/start?databases=AdventureWorks,AdventureWorks2

Launches the migration wizard, skipping the page which asks the user whether or not they want to start a new session, and goes directly to step 1 of the wizard with the databases AdventureWorks and AdventureWorks2 automatically selected.

azuredatastudio://Microsoft.sql-migration/start?databases=__all

Launches the migration wizard, skipping directly to step 1 of the wizard, with all databases automatically selected.

WIP:

support adding a new connection via URI

Pull Request Test Coverage Report for Build 2619478079

0 of 0   changed or added relevant lines in 0 files are covered.
No unchanged relevant lines lost coverage.
Overall coverage remained the same at 42.338%

Totals

Change from base Build 2618420290:
0.0%

Covered Lines:
28337

Relevant Lines:
62439

💛  - Coveralls

@raymondroc are you still working on this PR?  If not, please close and reopen again once work resumes.  Thanks!

Closing older PR without recent activity.  Please reopen if working on this area again.

authors: coveralls kburtram raymondtruong


text:
Bump electron version to 25.9.6

This PR bumps the electron version to 25.9.6 and updates the ADS-sqlite version to 1.18.0 for our test suite.
*Need to follow up with the new distro hash

Pull Request Test Coverage Report for Build 7026187014

0 of 0   changed or added relevant lines in 0 files are covered.
No unchanged relevant lines lost coverage.
Overall coverage remained the same at 41.565%

Totals

Change from base Build 7024675834:
0.0%

Covered Lines:
30790

Relevant Lines:
69376

💛  - Coveralls

authors: coveralls lewis-sanchez


text:
Patch "gh" to fix CVE-2024-54132

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

[x] The toolchain has been rebuilt successfully (or no changes were made to it)
[x] The toolchain/worker package manifests are up-to-date
[x] Any updated packages successfully build (or no packages were changed)
[x] Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
[x] Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
[x] All package sources are available
[x] cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
[x] LICENSE-MAP files are up-to-date (./LICENSES-AND-NOTICES/SPECS/data/licenses.json, ./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md, ./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)
[x] All source files have up-to-date hashes in the *.signatures.json files
[x] sudo make go-tidy-all and sudo make go-test-coverage pass
[x] Documentation has been updated to match any changes to the build system
[ ] Ready to merge

Summary

Patch gh to fix CVE-2024-54132
Change Log

CVE-2024-54132

Does this affect the toolchain?

NO
Links to CVEs

https://nvd.nist.gov/vuln/detail/CVE-2024-54132

Test Methodology

Pipeline build id: Buddy Build 693749

Auto cherry-pick results:

3.0-dev :x: -> https://github.com/microsoft/azurelinux/pull/11465

Auto cherry-pick pipeline run -> https://dev.azure.com/mariner-org/mariner/_build/results?buildId=693970&view=results

repo: microsoft/azurelinux


text:
Avoid recreating resources when not needed

Sub-sequent calls to terraform plan or terraform apply against an already provisioned cluster recreates the ACR pull role assignment for the Managed Identity.
As per the discussion over at https://github.com/hashicorp/terraform/issues/22005 this fix will mitigate that behaviour.
The added query section is merely there to create an implicit dependency between the cluster resource and the msi_object_id resource which will move the read from the apply-phase to the plan phase where it will evaluate to a non-changed value.

/AzurePipelines run

We removed the msi_object_id in this file in main branch. Closing.

authors: andrebriggs mickeahlinder

repo: microsoft/bedrock


text:
Update dependency Microsoft.Extensions.Configuration to 5.0.0

Fixes #5751
Description
This updates Microsoft.Extensions.Configuration from version 2.1.0 to 5.0.0 for TargetFramework netcoreapp3.1.
For netcoreapp2.1, version 2.1.0 must be kept because later versions are not compatible.
Specific Changes

Testing

Pull Request Test Coverage Report for Build 265143

0 of 0   changed or added relevant lines in 0 files are covered.
3 unchanged lines in 2 files lost coverage.
Overall coverage decreased (-0.01%) to 75.769%

Files with Coverage Reduction
New Missed Lines
%

/libraries/AdaptiveExpressions/BuiltinFunctions/GetPreviousViableTime.cs
1
90.91%

/libraries/AdaptiveExpressions/BuiltinFunctions/GetNextViableTime.cs
2
90.91%

Totals

Change from base Build 264914:
-0.01%

Covered Lines:
23136

Relevant Lines:
30535

💛  - Coveralls

authors: BruceHaley coveralls

repo: microsoft/botbuilder-dotnet


text:
feat: [#4684] Consolidate and update browser-echo-bot dependencies

Addresses #4684
#minor
Description
This PR updates the browser-echo-bot dependencies to their latest version. Additionally, it consolidates the project with the rest of the botbuilder libraries with workspaces, so latest changes are taken into consideration when testing them from a bot perspective.
Specific Changes

Update all browser-echo-bot dependencies to their latest version.
Added crypto-browserify dependency to address an issue with latest botbuilder version in the browser.
Removed resolutions inside the browser-echo-bot, since they are no longer needed.
Removed the section style from the browser-echo-bot, since was causing to display the webchat incorrectly.
Removed browser-echo-bot yarn.lock, to consolidate the dependencies into the root's yarn.lock.
Updated browser-echo-bot CI pipeline to work with the new structure.

Testing
The following image shows the functional pipeline and the bot working correctly.

Pull Request Test Coverage Report for Build 11186399843
Details

0 of 0   changed or added relevant lines in 0 files are covered.
No unchanged relevant lines lost coverage.
Overall coverage decreased (-0.4%) to 84.997%

Totals

Change from base Build 11164635173:
-0.4%

Covered Lines:
20351

Relevant Lines:
22910

💛  - Coveralls

authors: coveralls sw-joelmut

repo: microsoft/botbuilder-js


text:
CalculatorApp.exe is not executable...

Describe the bug
I try to build the Calculator for a computer without entry to the Microsoft Store. After I compile the project with Visual Studio inside my project folder the CalculatorApp.exe appears. Unfortunately this exe is not executable. Every time I try to start the exe nothing happens. When I simultaneously open the Task Manager I can see that the exe start and cancel after a few seconds. Inside the Event Viewer two error messages appear(see first two screenshots). When I debug the project in Visual Studio the calculator starts normally.
When I create a Setup Launcher for the project the application it cant installed the application probably, without the change of the Microsoft.NET dependency from .NET Framework 4.7.2 to Any, although the requested version is installed(see screenshot 3 and 4). While the build process of the Setup Launcher several warning appears(see screenshot 4 and 5). Likewise the warning before the requested dependencies are available on the system. While my search I discovered that maybe some file path are not resolved correctly(see screenshot 7). All in all i can not find the reason why the creation of a working exe is not working. Maybe some compatibility issues...
Can someone maybe describe the correct steps how to create a working exe of the Calculator?
So why run the calculator after I debug the project in Visual Studio, but not when I try to open the exe?
Steps To Reproduce
Steps to reproduce the behavior:

Download a version of the project with is compatible with Win 10.
Follow the instructions of the "Getting Started".
Build Solution with Visual Studio.
Open exe in the project folder.
See error

Expected behavior
The Calculator can be installed on the computer normally.
Screenshots
1.

Device and Application Information

OS Build: 10.0.20348.0
Architecture: x64
Application Version:
Region:de-De
Dev Version Installed:

Additional context
I work on a 2022 Server environment, but I can reproduce the error on a Win 10 Pro and a Win 11 Pro environment.
Requested Assignment

If possible, I would like to fix this.

Hi, could you assign me to it so that I can try and fix the problem for you

Hi, could you assign me to this task.

repo: microsoft/calculator


text:
500 Internal Server error  RN clarity sdk

Followed all documented steps.
anybody else facing the same issue?

@vivek0046 Thanks for reporting this, we had a few backend issues at that timeframe, but things should have stabilized soon after. Could you please confirm that the problem has been resolved on your end?

@vivek0046 Thanks for reporting this, we had a few backend issues at that timeframe, but things should have stabilized soon after. Could you please confirm that the problem has been resolved on your end?

Hi,thanks for update
We will try again.

repo: microsoft/clarity-apps


text:
[BUG] npx init fails on Win10/Git Bash

Context:

Playwright Version: [what Playwright version do you use?] latest via npx init playwright
Operating System: [e.g. Windows, Linux or Mac] Win 10 64-bit
Node.js version: [e.g. 12.22, 14.6] 7.24.1
Browser: [e.g. All, Chromium, Firefox, WebKit] via npx init playwright
Extra: [any specific details about your environment] git bash 4.4.23

  System:
    OS: Windows 10 10.0.19043
    Memory: 8.11 GB / 15.94 GB
  Binaries:
    Node: 16.10.0 - L:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - L:\_npm\yarn.CMD
    npm: 7.24.1 - L:\_npm\npm.CMD
  Languages:
    Bash: 4.4.23 - L:\Program Files\Git\usr\bin\bash.EXE

Code Snippet
Help us help you! Put down a short code snippet that illustrates your bug and
that we can run and debug locally. For example:
pm init playwright

Describe the bug
leege@studio MINGW64 /l/src/nta/nta-test (master)
$ npm init playwright
Getting started with writing end-to-end tests with Playwright:
Initializing project in '.'
√ Do you want to use TypeScript or JavaScript? · TypeScript
√ Where to put your end-to-end tests? · .
√ Add a GitHub Actions workflow? (Y/n) · true
Initializing NPM project (npm init -y)…
Wrote to L:\src\nta\nta-test\package.json:

{
  "name": "nta-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

Installing Playwright Test (npm install --save-dev @playwright/test)…

added 208 packages, and audited 209 packages in 16s

20 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Downloading browsers (npx playwright install)…
'playwright' is not recognized as an internal or external command,
operable program or batch file.
Error: Command failed: npx playwright install
    at checkExecSyncError (node:child_process:826:11)
    at execSync (node:child_process:900:15)
    at executeCommands (C:\Users\leege\AppData\Local\npm-cache\_npx\d40a10098bccdd29\node_modules\create-playwright\lib\index.js:1:85854)
    at Generator.run (C:\Users\leege\AppData\Local\npm-cache\_npx\d40a10098bccdd29\node_modules\create-playwright\lib\index.js:1:80307)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async C:\Users\leege\AppData\Local\npm-cache\_npx\d40a10098bccdd29\node_modules\create-playwright\lib\index.js:1:79571 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 14608,
  stdout: null,
  stderr: null
}
npm ERR! code 1
npm ERR! path L:\src\nta\nta-test
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c create-playwright

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\leege\AppData\Local\npm-cache\_logs\2022-02-24T08_58_52_040Z-debug.log

I tried to reproduce but it was working for me with the exact same npm/node version and inside git bash with mingw.
You should not have to adjust something manually inside the path and npx playwright should just work.
Could you try executing npx playwright --help inside your repo?

'playwright' is not recognized as an internal or external command,
operable program or batch file.```

Very weird! Seems like something is off with your NPM/Node.js installation. Could you try upgrading to NPM 8?
npm i -g npm@8

Yeah, it's me -- I don't know why yet, but I'm seeing the same with Stencil's entry in .bin....

authors: leegee mxschmitt

repo: microsoft/create-playwright


text:
Dev Box Hibernate support

Suggested new feature or improvement
With Dev Box shipping out hibernate support for more VMs, Dev Home & Azure Extension might need to make changes to support it better.
Scenario
Hibernating of Dev Boxes is seamlessly supported.
Additional details
No response

Moving to P3 as this needs discussion.

repo: microsoft/devhome


text:
Hopefully you can add a star to GitHub

Suggested new feature or improvement
Hopefully you can add a star to GitHub
Scenario
Hopefully you can add a star to GitHub
Additional details
No response

Hi @RBHakureiReimu. There's not enough information here to understand what you're asking for, and therefore nothing we can do. If you want to add more details about your feature suggestion, I might be able to re-open this issue.

authors: RBHakureiReimu krschau


text:
Terminate the target process, restart it, PI shows (terminated) multiple times

Dev Home version
0.503
Windows build number
10.0.22631.3672
Other software
No response
Steps to reproduce the bug

Run PI, and associate with some app.
Go to Expanded mode
Terminate the target process.
See we append (terminated).
Restart the target app, and associate PI with it (via process list or hotkey)
Terminate the target process again.
See we append (terminated) (terminated)

Expected result
No response
Actual result
(terminated) is repeated.

Included System Information
No response
Included Extensions Information
No response

No repro

authors: andreww-msft zadesai