Unable to compile TypeScript when using several datatables.net plugins

Unable to compile TypeScript when using several datatables.net plugins

ZeshueToralZeshueToral Posts: 10Questions: 4Answers: 0

Description of problem:
I am trying to use datatables.net with the buttons, colreorder, fixedcolumns, select, and fixedheader plugins in an ASP.NET Core app that uses typescript, but when I try to use all of the type definitions, I am unable to compile the TS due to a Maximum call stack size exceeded error in the tsc compilation command. After digging into it a little, it appears that this is coming from the extensions of the API in the types.d.ts files such as interface ApiColReorderMethods<T> extends Omit<Api<T>, 'order'> in the ColReorder plugin. It seems to have to do with the generics that are being passed with these interface extensions (and then subsequently the contained methods have return types of Api<T>, which I believe recurses this) since by making the interface extensions non-generic and / or removing the generic typing from Api (which it doesn't really seem to need?) in one of the plugins seems to resolve this issue. I also have identified that there are 3 different plugins (buttons, colreorder, fixedheader) that I am using that, once removed, also resolve this problem. This makes me think that it's a cumulative issue in the TypeScript compiler rather than a single problematic plugin that's causing it.

Examples of where generic type <T> is omitted or not used:
export interface AjaxMethods extends Api<any> in datatables.net types.d.ts - Api type is provided with <any> as the generic type (which is the default anyway as specified by <T=any> where it's being exported)
interface ApiButtonMethods<T> extends Api<T> in datatables.net-buttons types.d.ts - Generic present but all Api return types use Api<any> and the generic type is not consumed anywhere.

I'm not super familiar with TypeScript, but it doesn't seem to make a difference if the generic <T> is removed from the interface extensions of Api (but I could also be mistaken). It also seems like this has maybe already been done in some places where return types of the interface extension properties are marked as just : Api or : Api<any>, or the generic <T> just isn't used at all.

Link to test case:
https://github.com/Zeshue/datatables.net-ts-problem-example
Steps to reproduce in test case:
1. Restore Client-Side libraries
2. Try to rebuild or run the code in Visual Studio OR run this command (pointing at the tsconfig.json file in the project folder) C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\NodeJs\node.exe %USERPROFILE%\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js --project "%USERPROFILE%\source\repos\Test\TS_TEST\TS_TEST\tsconfig.json" --listEmittedFiles --locale en-US

Error messages shown:
On dotnet build / run:
Task "VsTsc" 1> C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\NodeJs\node.exe C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js --project "C:\Users\zeshue\source\repos\Test\TS_TEST\TS_TEST\tsconfig.json" --listEmittedFiles --locale en-US 1> Unknown output: throw e; 1> Unknown output: ^ 1> Unknown output: at propertiesRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:65124:33) 1> Unknown output: at structuredTypeRelatedToWorker (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:64809:21) 1> Unknown output: at structuredTypeRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:64265:21) 1> Unknown output: at recursiveTypeRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:64216:19) 1> Unknown output: at isRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:63634:122) 1> Unknown output: at isRelatedToWorker2 (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:65429:16) 1> Unknown output: at compareSignaturesRelated (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:62994:14) 1> Unknown output: at signatureRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:65427:14) 1> Unknown output: at signaturesRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:65333:27) 1> Unknown output: at structuredTypeRelatedToWorker (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:64820:24) 1> Unknown output: Node.js v20.13.1 1> Assembly loaded during TaskRun (TypeScript.Tasks.VsTsc): System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (location: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IO\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.IO.dll, MVID: a3dc1039-60bf-4164-8172-9586479e1175, AppDomain: [Default]) 1> Assembly loaded during TaskRun (TypeScript.Tasks.VsTsc): System.IO.FileSystem.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (location: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IO.FileSystem.Primitives\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.IO.FileSystem.Primitives.dll, MVID: a939ef74-d6ad-48a3-a15f-c984f15f836a, AppDomain: [Default]) 1> C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\Microsoft.TypeScript.targets(485,5): error MSB6006: "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\NodeJs\node.exe" exited with code 1.

Looking at this build output points to the issue stemming from the tsc command on the first line of the error, so I ran that command (C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\NodeJs\node.exe C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js --project "C:\Users\zeshue\source\repos\Test\TS_TEST\TS_TEST\tsconfig.json" --listEmittedFiles --locale en-US) separately and get this:
RangeError: Maximum call stack size exceeded at getTypeOfParameter (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:76201:30) at isTopSignature (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:62876:61) at compareSignaturesRelated (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:62887:81) at compareSignaturesRelated (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:62948:35) at signatureRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:65427:14) at signaturesRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:65333:27) at structuredTypeRelatedToWorker (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:64820:24) at structuredTypeRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:64265:21) at recursiveTypeRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:64216:19) at isRelatedTo (C:\Users\zeshue\.nuget\packages\microsoft.typescript.msbuild\5.6.2\tools\tsc\tsc.js:63634:122)

Answers

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    I'm sruggling to get information out of dotnet build unfortunately. I'm using a linux system, so using the dotnet CLI and I do get an error, but no useful information:

    $ dotnet build --debug
    MSBuild version 17.8.5+b5265ef37 for .NET
      Determining projects to restore...
      All projects are up-to-date for restore.
    /home/vagrant/.nuget/packages/microsoft.typescript.msbuild/5.6.2/tools/Microsoft.TypeScript.targets(485,5): error MSB6006: "/home/vagrant/.nvm/versions/node/v20.15.1/bin/node" exited with code 1. [/home/vagrant/xxtmp/datatables.net-ts-problem-example/TS_TEST/TS_TEST.csproj]
    
    Build FAILED.
    
    /home/vagrant/.nuget/packages/microsoft.typescript.msbuild/5.6.2/tools/Microsoft.TypeScript.targets(485,5): error MSB6006: "/home/vagrant/.nvm/versions/node/v20.15.1/bin/node" exited with code 1. [/home/vagrant/xxtmp/datatables.net-ts-problem-example/TS_TEST/TS_TEST.csproj]
        0 Warning(s)
        1 Error(s)
    
    Time Elapsed 00:00:03.76
    

    So I tried to create an example with the same software, and it appears to run okay with Vite.

    Any idea how I can get more info from the CLI?

    Allan

  • ZeshueToralZeshueToral Posts: 10Questions: 4Answers: 0

    Hey @allan, if you run dotnet build -v detailed it will give you a much more detailed output for the build. For some reason it only seems to give the stack trace and omits the "Maximum call stack size exceeded" part though, hence why I included the part about running the TypeScript compiler with Node directly.

Sign In or Register to comment.