microsoft / Kusto-Query-Language

Kusto Query Language is a simple and productive language for querying Big Data.
Apache License 2.0
510 stars 97 forks source link

Typing errors on JS version #72

Closed gonza-lito closed 1 year ago

gonza-lito commented 2 years ago

Hi, we're using the JS version of the packages and noticed the typings are not correct, I can't find Bridge.NET library anywhere to see how those typings are generated.

Typing errors:

  Named property 'GetEnumerator' of types 'SyntaxList' and 'IReadOnlyList$1<TElement>' are not identical.

15915     interface SyntaxList$1<TElement> extends Kusto.Language.Syntax.SyntaxList,System.Collections.Generic.IReadOnlyList$1<TElement> {
                    ~~~~~~~~~~~~

node_modules/@kusto/language-service-next/Kusto.Language.Bridge.d.ts:15915:15 - error TS2320: Interface 'SyntaxList$1<TElement>' cannot simultaneously extend types 'SyntaxList' and 'IReadOnlyList$1<TElement>'.
  Named property 'getItem' of types 'SyntaxList' and 'IReadOnlyList$1<TElement>' are not identical.

15915     interface SyntaxList$1<TElement> extends Kusto.Language.Syntax.SyntaxList,System.Collections.Generic.IReadOnlyList$1<TElement> {
                    ~~~~~~~~~~~~

node_modules/@kusto/language-service-next/Kusto.Language.Bridge.d.ts:15917:29 - error TS2694: Namespace 'System' has no exported member 'Type'.

15917         ElementType: System.Type | null;
                                  ~~~~

node_modules/@kusto/language-service-next/Kusto.Language.Bridge.d.ts:22280:29 - error TS2694: Namespace 'System' has no exported member 'Type'.

22280         ElementType: System.Type | null;
                                  ~~~~

Found 4 errors.

Any information would be much appreciated! Thx

mattwar commented 2 years ago

This is a problem with the Bridge.NET generated .d.ts file. Bridge.NET tries to represent the C# source in as close as possible form, but Typescript does not allow this kind of duplication of inheritance, so this is one place Bridge gets it wrong. It's not a problem for the translated Javascript itself, since Bridge uses its own translation to Javascript (not Typescrip;t's), and the Typescript .d.ts file is for convenience only.

Unfortunately, there is no one to complain to, as Bridge.NET is no longer supported by the creators. It is still being used in this project. However, this is not a problem since this kind of error only surfaces for Typescript when you directly interact with a member in violation of Typescript's rules. The Javascript translation of this project is used for Intellisense in the web editor, which only uses the CodeService API's which do not cause the problem to surface.

The only workaround that I've found is to hand edit the generated .d.ts file and remove the claim that SyntaxList implements the interface.