Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Seemingly swapped or incomplete type inference for Decorators in 2.4.1 #17264

Closed
ghost opened this issue Jul 18, 2017 · 2 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@ghost
Copy link

ghost commented Jul 18, 2017

TypeScript Version: 2.4.1

Since 2.4.1 TypeScript is outright hating my decorated classes due to following problem:

abstract class BaseType {
}

class ImplementingType {
	value = 1;
}

abstract class BaseClass<W extends BaseType> {
	abstract test(baseValue: W): void;
}

function Decorator(target:typeof BaseClass) {
}

@Decorator
class ImplementingClass extends BaseClass<ImplementingType> {
	test(implementValue:ImplementingType) {
		return;
	}
}

Expected behavior:
There should be no error in this. ImplementingClass is an implementation of BaseClass and ImplementingType extends BaseType.

Actual behavior:
Mind the swap of assigns in the error stack in "Type 'W' is not assignable to type 'ImplementingType'."

error TS2345: Argument of type 'typeof ImplementingClass' is not assignable to parameter of type 'typeof BaseClass'.
  Type 'ImplementingClass' is not assignable to type 'BaseClass<W>'.
    Types of property 'test' are incompatible.
      Type '(implementValue: ImplementingType) => void' is not assignable to type '(baseValue: W) => void'.
        Types of parameters 'implementValue' and 'baseValue' are incompatible.
          Type 'W' is not assignable to type 'ImplementingType'.
            Type 'BaseType' is not assignable to type 'ImplementingType'.
              Property 'value' is missing in type 'BaseType'.

@ikatyang
Copy link
Contributor

It seems duplicate of #16985, and it's caused by stricter generic checks (#16368), if you don't like this feature, you may have to enable --noStrictGenericChecks option.

@ikatyang ikatyang marked this as a duplicate of #16985 Jul 18, 2017
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jul 18, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Aug 17, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Aug 17, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants