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 bug - false typescript error with regards to generics and generics inference #28445

Closed
noam-honig opened this issue Nov 9, 2018 · 5 comments · Fixed by #31574
Closed
Assignees
Labels
Bug A bug in TypeScript

Comments

@noam-honig
Copy link

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
@vscodebot vscodebot bot assigned mjbvz Nov 9, 2018
@mjbvz mjbvz transferred this issue from microsoft/vscode Nov 9, 2018
@mjbvz mjbvz 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 Nov 9, 2018
@DanielRosenwasser DanielRosenwasser added the Needs Investigation This issue needs a team member to investigate its status. label Nov 9, 2018
@DanielRosenwasser DanielRosenwasser assigned sandersn and unassigned mjbvz Nov 9, 2018
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.3 milestone Nov 9, 2018
@noam-honig
Copy link
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

@noam-honig
Copy link
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.

@RyanCavanaugh RyanCavanaugh assigned weswigham and unassigned sandersn Mar 14, 2019
@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript and removed Needs Investigation This issue needs a team member to investigate its status. labels Mar 14, 2019
@RyanCavanaugh
Copy link
Member

Regression starting at 3.1

@noam-honig
Copy link
Author

@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?

@weswigham
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants