Skip to content

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

Closed

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

Activity

  1. changed the title [-]Regression bug - syntax highlight displays false typescript error with regards to generics and generics inference[/-] [+]Regression bug - false typescript error with regards to generics and generics inference[/+] on Nov 9, 2018
  2. noam-honig commented on Nov 11, 2018

    @noam-honig
    Author

    Just to clarify - it's not a typescript build error (at least in the typescript version I'm building with) - it's an error syntax highlight in VS Code

  3. noam-honig commented on Nov 11, 2018

    @noam-honig
    Author

    One more clarification - I confirmed that in typescript 3.1.6 it's a build error.
    Previously in TypeScript 2.5.3 - it worked as expected without any build errors or syntax highlight errors.

  4. added
    BugA bug in TypeScript
    and removed
    Needs InvestigationThis issue needs a team member to investigate its status.
    on Mar 14, 2019
  5. RyanCavanaugh commented on Mar 14, 2019

    @RyanCavanaugh
    Member

    Regression starting at 3.1

  6. noam-honig commented on Jun 20, 2019

    @noam-honig
    Author

    Wesley Wigham (@weswigham) I've retested this using the latest vscode and typescript 3.5.1 and it's still not working - how can I test if it was fixed?

  7. weswigham commented on Jun 20, 2019

    @weswigham
    Member

    You'd have to use the nightly - typescript@next - and configure vscode to use the installed version of typescript.

  8. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions