Skip to content

Regression bug - false typescript error with regards to generics and generics inference #28445

Closed
@noam-honig

Description

@noam-honig

Issue Type: Bug

I use a complex structure of classes, interfaces and generics.

The generic type is inferred by the first paramter of the class constructor.
In the current version I get a syntax highlight error that I did not receive in older versions (few month ago).

Here are some screenshots - and the code is below:
image

And the errors are:
image
and:
image

Here's the type script code with two members - one that get's the syntax error and one that works.

class ClassA<classType>  {
  constructor(private entity?: classType, public settings?: SettingsInterface<classType>) {

  }
}
export interface valueInterface<classType> {
  func?: (row: classType) => any;
  value?: string;
}
export interface SettingsInterface<classType> {
  values?: (row: classType) => valueInterface<classType>[],
}
class myClass{
    theName='myClass';
}

var thisGetsTheFalseError = new ClassA(new myClass(), {
  values: o => [
    {
      value: o.theName,
      func: x => 'asdfkjhgfdfghjkjhgfdfghjklkjhgfdfghjklkjhgfghj'
    }
  ]
});
var thisIsOk = new ClassA<myClass>(new myClass(), {
  values: o => [
    {
      value: o.theName,
      func: x => 'asdfkjhgfdfghjkjhgfdfghjklkjhgfdfghjklkjhgfghj'
    }
  ]
});

VS Code version: Code 1.28.2 (7f3ce96ff4729c91352ae6def877e59c561f4850, 2018-10-17T00:23:51.859Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-5930K CPU @ 3.50GHz (12 x 3500)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 31.84GB (17.33GB free)
Process Argv --folder-uri file:///c%3A/Repos/radweb
Screen Reader no
VM 0%
Extensions (4)
Extension Author (truncated) Version
ng-template Ang 0.1.10
githistory don 0.4.3
gitlens eam 8.5.6
debugger-for-chrome msj 4.11.0

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions