Home > OS >  TypeScript version mismatch in Visual Studio 2022
TypeScript version mismatch in Visual Studio 2022

Time:02-16

With a web project set to use 4.4 explicitly via the Projet Properties, TypeScript Build: TypeScript Build settings Note that it says "unavailable".

I get this warning when opening the project with VS2022: PROJECT.X specifies TypeScript version 4.4, but a matching compiler was not found. Would you like us to update your project to use TypeScript 4.3? Update Typescript dialog

If I change the TypeScript version to "Use latest available": TypeScript Build settings

On loading, the warning becomes: PROJECT.X is built using TypeScript 4.3, but the TypeScript language service version currently in use by Visual Studio is 4.4. This may be caused by other projects in the solution using a different version of TypeScript. Would you like us to update your project to use TypeScript 4.4? Update Typescript dialog

So these seem to say VS has a 4.4 language service, but not the matching compiler?

I have read:

  • location of external tools

    With that, I get the warnings above (one of them, depending the TypeScript Version 4.4 or Latest, on the web project properties).

    If I uncheck or remove $(VSInstalledExternalTools) (rather than move PATH to the top), the warnings go away.

    Having removed $(VSInstalledExternalTools), I now add a fake $(SomethingRandom) at the top of the list, the warnings come back.

    As I posted here location of external tools

    CodePudding user response:

    To find all your TypeScript compilers versions, try running this powershell:

    Get-Childitem –Path C:\,D:\ -Recurse -Force -Include tsc.cmd -ErrorAction SilentlyContinue | foreach { $_.FullName; & $_ -v }

    this would help in reconciling the order of the locations above, whether these folders are in your Path variable, etc.

    My output is something like this:

    C:\Users\BobSMith\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\.bin\tsc.cmd
    Version 4.1.6
    C:\Users\BobSMith\AppData\Roaming\npm\tsc.cmd
    Version 4.5.5
    D:\$RECYCLE.BIN\S-1-12-1-732868070-XXX-XXX-XXX\$RH58AY6.1\src\XXX\XXX.Web\node_modules\.bin\tsc.cmd
    Version 3.8.3
    D:\code\XXX\XXX.Web\node_modules\.bin\tsc.cmd
    Version 3.4.5
    D:\code\YYY\YYY.Web\node_modules\.bin\tsc.cmd
    Version 4.4.2
    D:\code\XXX\ZZZ\node_modules\.bin\tsc.cmd
    Version 4.2.4
    
  • Related